angular access service in console
angular.element(document.body).injector().get('serviceName')
Here is what the above code is Doing:
1. Get the body element
2. Get the injector from the body element
3. Get the service from the injector
angular.element(document.body).injector().get('serviceName')
Here is what the above code is Doing:
1. Get the body element
2. Get the injector from the body element
3. Get the service from the injector
// Does NOT delete files that exist in targetDir but do not exist in srcDir fse.copySync(srcDir, targetDir, {overwrite: true}); // Does delete files that exist in targetDir but do not exist in srcDir // Use if you want targetDir === srcDir fse.moveSync(srcDir, targetDir, {overwrite: true}); Here is what the above code is Doing: 1. Create…
import { SocialAuthService } from “angularx-social-login”;import { FacebookLoginProvider, GoogleLoginProvider } from “angularx-social-login”; @Component({ selector: ‘app-demo’, templateUrl: ‘./demo.component.html’, styleUrls: [‘./demo.component.css’]})export class DemoComponent implements OnInit { constructor(private authService: SocialAuthService) { } signInWithGoogle(): void { this.authService.signIn(GoogleLoginProvider.PROVIDER_ID); } signInWithFB(): void { this.authService.signIn(FacebookLoginProvider.PROVIDER_ID); } signOut(): void { this.authService.signOut(); } } Here is what the above code is Doing: 1. We are importing the SocialAuthService from angularx-social-login. 2. We are importing the FacebookLoginProvider and GoogleLoginProvider from angularx-social-login. 3. We are injecting the SocialAuthService in the constructor. 4. We are calling the signIn() method of the SocialAuthService and passing the FacebookLoginProvider.PROVIDER_ID as a parameter. 5. We…
const fs = require(‘fs’); fs.appendFile(‘message.txt’, ‘data to append’, function (err) { if (err) throw err; console.log(‘Saved!’); }); Here is what the above code is Doing: 1. We’re requiring the fs module. 2. We’re appending the string ‘data to append’ to the file ‘message.txt’. 3. If there’s an error, we throw it. 4. If there’s no…
var form_data = new FormData(); for ( var key in item ) { form_data.append(key, item[key]); } $.ajax({ url : ‘http://example.com/upload.php’, data : form_data, processData : false, contentType : false, type: ‘POST’ }).done(function(data){ // do stuff }); Here is what the above code is Doing: 1. Create a new FormData object. 2. Loop through the item…
var myString = “this.is.my.file.txt” alert(myString.substring(myString.lastIndexOf(“.”) + 1)); // Result txt Here is what the above code is Doing: 1. We create a string variable called myString and assign it a value of “this.is.my.file.txt”. 2. We then use the substring() method to extract the characters from the myString variable starting at the lastIndexOf(“.”) + 1. 3….
use position properites eg relative,absoulute then apply css Here is what the above code is Doing: 1. We’re creating a new class called .box. 2. We’re setting the width and height of the .box class to be 100px. 3. We’re setting the background color of the .box class to be blue. 4. We’re setting the…