1563937446
In this tutorial, we’ll learn how to use external and custom JavaScript libraries/code in Angular 8 projects which are based on TypeScript.
You will need to have the following prerequisites:
npm install -g @angular/cli
),You can create an Angular project by running the following command in your terminal:
$ ng new angular-javascript-demo
In the recent versions of Angular, you’ll be prompted by the CLI for a couple of questions such as if Would you like to add Angular routing? (y/N) and Which stylesheet format would you like to use?. You can answer these questions as you see fit because this won’t affect how to use JavaScript libraries in your Angular project.
Let’s now see how we can use external JavaScript in Angular 8. We’ll make use of the popular jQuery library as an example.
Note*: Please note that it’s not recommended to use jQuery for maniplulating the DOM in Angular. This is simply an example of including an external JS library in Angular.*
If your library is popular you’ll most likl you can install it from npm. In you terminal, navigate to your project’s folder and run install jquery:
$ npm install jquery --save
Next, open the angular.json
file and locate the scripts
array and update as follows:
"scripts": [
"node_modules/jquery/dist/jquery.min.js"
]
Next, in the component where you want to call your external library you need to declare the JavaScript symbol you want to call. For example, for jQuery, we need add the following line:
declare var jQuery: any;
Next, you can call the required functions as in the following example:
import { Component, OnInit } from '@angular/core';
declare var jQuery: any;
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
name = 'Angular';
ngOnInit(){
(function ($) {
$(document).ready(function(){
console.log("Hello from jQuery!");
});
})(jQuery);
}
}
Let’s now see how we can use custom JavaScript in Angular.
First, create a JavaScript file inside the src/
folder, add the following code as example:
(function hello() {
alert('Hello!!!');
})()
Next, add the script to the scripts
array in the angular.json
file:
"scripts": [
"src/custom.js"
]
You can also simply declare and call your JavaScript functions in any component since it’s a TypeScript file. For example:
import { Component, OnInit } from '@angular/core';
function hello() {
alert('Hello!!!');
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
name = 'Angular';
ngOnInit(){
hello()
}
}
Originally published at*** techiediaries.com ***on 22 Jul 2019
#javascript #angular #typescript #web-development
1625034420
Today I will show you How to Send E-mail Using Queue in Laravel 7/8, many time we can see some process take more time to load like payment gateway, email send, etc. Whenever you are sending email for verification then it load time to send mail because it is services. If you don’t want to wait to user for send email or other process on loading server side process then you can use queue.
#how to send e-mail using queue in laravel 7/8 #email #laravel #send mail using queue in laravel 7 #laravel 7/8 send mail using queue #laravel 7/8 mail queue example
1598727360
Angular 8 Updates And Summary of New Features is today’s topic. Angular 8 arrives with an impressive list of changes and improvements including the much-anticipated Ivy compiler as an opt-in feature. You can check out Angular 7 features and updates if you have not seen yet. In this blog, we have written some articles about Angular 7 Crud, Angular 7 Routing, Angular ngClass, Angular ngFor.
See the following updates.
Angular 8.0 is now supported TypeScript 3.4, and even requires it, so you will need to upgrade.
You can look at what TypeScript 3.3 and TypeScript 3.4 brings on the table on official Microsoft blog.
#angular #typescript #angular 7 crud #angular 7 routing #angular 8
1608113009
What is new in New Angular 7? New Angular 7 features have turned out as a powerful release that really brought advancement in the application development structure.
Here, we have listed new Angular 7 features with examples and write the difference between Angular 6 and Angular 7.
Read more: Angular 7 Features With Example
#angular 7 features #what’s new angular 7 #new angular 7 features #angular 7 features with examples
1563937446
In this tutorial, we’ll learn how to use external and custom JavaScript libraries/code in Angular 8 projects which are based on TypeScript.
You will need to have the following prerequisites:
npm install -g @angular/cli
),You can create an Angular project by running the following command in your terminal:
$ ng new angular-javascript-demo
In the recent versions of Angular, you’ll be prompted by the CLI for a couple of questions such as if Would you like to add Angular routing? (y/N) and Which stylesheet format would you like to use?. You can answer these questions as you see fit because this won’t affect how to use JavaScript libraries in your Angular project.
Let’s now see how we can use external JavaScript in Angular 8. We’ll make use of the popular jQuery library as an example.
Note*: Please note that it’s not recommended to use jQuery for maniplulating the DOM in Angular. This is simply an example of including an external JS library in Angular.*
If your library is popular you’ll most likl you can install it from npm. In you terminal, navigate to your project’s folder and run install jquery:
$ npm install jquery --save
Next, open the angular.json
file and locate the scripts
array and update as follows:
"scripts": [
"node_modules/jquery/dist/jquery.min.js"
]
Next, in the component where you want to call your external library you need to declare the JavaScript symbol you want to call. For example, for jQuery, we need add the following line:
declare var jQuery: any;
Next, you can call the required functions as in the following example:
import { Component, OnInit } from '@angular/core';
declare var jQuery: any;
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
name = 'Angular';
ngOnInit(){
(function ($) {
$(document).ready(function(){
console.log("Hello from jQuery!");
});
})(jQuery);
}
}
Let’s now see how we can use custom JavaScript in Angular.
First, create a JavaScript file inside the src/
folder, add the following code as example:
(function hello() {
alert('Hello!!!');
})()
Next, add the script to the scripts
array in the angular.json
file:
"scripts": [
"src/custom.js"
]
You can also simply declare and call your JavaScript functions in any component since it’s a TypeScript file. For example:
import { Component, OnInit } from '@angular/core';
function hello() {
alert('Hello!!!');
}
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
name = 'Angular';
ngOnInit(){
hello()
}
}
Originally published at*** techiediaries.com ***on 22 Jul 2019
#javascript #angular #typescript #web-development
1593184320
What is Angular? What it does? How we implement it in a project? So, here are some basics of angular to let you learn more about angular.
Angular is a Typescript-based open-source front-end web application platform. The Angular Team at Google and a community of individuals and corporations lead it. Angular lets you extend HTML’s syntax to express your apps’ components clearly. The angular resolves challenges while developing a single page and cross-platform applications. So, here the meaning of the single-page applications in angular is that the index.html file serves the app. And, the index.html file links other files to it.
We build angular applications with basic concepts which are NgModules. It provides a compilation context for components. At the beginning of an angular project, the command-line interface provides a built-in component which is the root component. But, NgModule can add a number of additional components. These can be created through a template or loaded from a router. This is what a compilation context about.
Components are key features in Angular. It controls a patch of the screen called a view. A couple of components that we create on our own helps to build a whole application. In the end, the root component or the app component holds our entire application. The component has its business logic that it does to support the view inside the class. The class interacts with the view through an API of properties and methods. All the components added by us in the application are not linked to the index.html. But, they link to the app.component.html through the selectors. A component can be a component and not only a typescript class by adding a decorator @Component. Then, for further access, a class can import it. The decorator contains some metadata like selector, template, and style. Here’s an example of how a component decorator looks like:
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss']
})
Modules are the package of functionalities of our app. It gives Angular the information about which features does my app has and what feature it uses. It is an empty Typescript class, but we transform it by adding a decorator @NgModule. So, we have four properties that we set up on the object pass to @NgModule. The four properties are declarations, imports, providers, and bootstrap. All the built-in new components add up to the declarations array in @NgModule.
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
FormsModule
],
bootstrap: [AppComponent]
})
Data Binding is the communication between the Typescript code of the component and the template. So, we have different kinds of data binding given below:
#angular #javascript #tech blogs #user interface (ui) #angular #angular fundamentals #angular tutorial #basics of angular