| Start |
|---|
| Getting Started Create a new HTML file and paste the following content: When you open the file with a browser, you will see an input field followed by the text Explanation: Note that ng-init should be used for demonstrative and testing purposes only. When building an actual application, controllers should initialize the data. <input> to the name property with ng-model The last three steps establish the two way data-binding (opens new window). Changes made to the input update the model, which is reflected in the view. There is a difference between using handlebars and |
| Showcasing all common Angular constructs The following example shows common AngularJS constructs in one file: Every line of the file is explained below:
Three functions (
|
| The importance of scope As Angular uses HTML to extend a web page and plain Javascript to add logic, it makes it easy to create a web page using ng-app (opens new window), ng-controller (opens new window) and some built-in directives such as ng-if (opens new window), ng-repeat (opens new window), etc. With the new controllerAs syntax, newcomers to Angular users can attach functions and data to their controller instead of using However, sooner or later, it is important to understand what exactly this The good news is that it is a simple yet powerful concept. When you create the following: Where does name live? The answer is that Angular creates a And just as with global scope in Javascript, it's usually not such a good idea to add items to the global scope or Of course, most of the time, we create a controller and put our required functionality into that controller. But when we create a controller, Angular does it's magic and creates a So, creating the following controller: would allow the local scope to be accessible via the A controller without a As Then via the prototype chain, a child controller could access that same model locally with None of this is initially evident, as it's just Angular doing its magic in the background. But understanding |
| Minification in Angular What is Minification ? It is the process of removing all unnecessary characters from source code without changing its functionality. Normal Syntax If we use normal angular syntax for writing a controller then after minifiying our files it going to break our functionality. Controller (Before minification) : After using minification tool, It will be minified as like below. Here, minification removed unnecessary spaces and the $scope variable from code. So when we use this minified code then its not going to print anything on view. Because $scope is a crucial part between controller and view, which is now replaced by the small 'e' variable. So when you run the application it is going to give Unknown Provider 'e' dependency error. There are two ways of annotating your code with service name information which are minification safe: Inline Annotation Syntax $inject Property Annotation Syntax After minification, this code will be Here, angular will consider variable 'a' to be treated as $scope, and It will display output as 'Hello World !'. |
| AngularJS Getting Started Video Tutorials There are a lot of good video tutorials for the AngularJS framework on egghead.io (opens new window)
|
| The Simplest Possible Angular Hello World. Angular 1 is at heart a DOM compiler. We can pass it HTML, either as a template or just as a regular web page, and then have it compile an app. We can tell Angular to treat a region of the page as an expression using the This will output: ng-appWe tell Angular which portion of our DOM to treat as the master template using the I've now told the body element to be the root template. Anything in it will be compiled. DirectivesDirectives are compiler directives. They extend the capabilities of the Angular DOM compiler. This is why Misko, the creator of Angular, describes Angular as: "What a web browser would have been had it been built for web applications. We literally create new HTML attributes and elements, and have Angular compile them into an app.
Angular comes with around 100 built-in directives which allow you to accomplish most common tasks. We can also write our own, and these will be treated in the same way as the built in directives. We build an Angular app out of a series of directives, wired together with HTML. RemarksAngularJS is a web application framework designed to simplify rich client-side application development. This documentation is for Angular 1.x (opens new window), the predecessor of the more modern Angular 2 (opens new window) or see the Stack Overflow documentation for Angular 2 (opens new window). |
Read Article
https://develop.horje.com/learn/1434/reference