AngularJs Study (i)

Source: Internet
Author: User

Recently learned a bit about angularjs and found that there is something very similar to Vue. So it's better to understand what you've learned about Vue.

Features: bidirectional data binding, single page application

Controller:

The ANGULARJS controller can control DOM elements on a Web page or respond to click events on a Web page, all from $scope, which is the model (Ng-model) in view

Data channel. Among them, $scope played a role in data transfer.

To implement the controller, you must add Ng-controller (an instruction of angular) to the DOM element, which is bound to the view. When Angluar is loaded, it loads

Read the parameters of the Ng-controller.

Module:

A very important concept of ANGULARJS is--module, which is composed of multiple modules for a angular application. At the same time, the module is reusable and can be called in many places.

Template:

This place is an important part of the angular (also available in Vue) and is an important component of a project template. It can dynamically display different views (pages). which

If you use the module, you must use the Ng-template command, and use the module as a general and Ng-view (management view) directive.

Routing:

What routing is, is that we want to implement the page jump on the application, to implement such a function requires the use of routing to manage. Here is a description of the AngularJs1.2 version after the Ngroute was stripped out separately,

A re-reference is required. The $routeprovider declaration route provided by the Angularjs $route

Factory Method:

This is a bit like the factory approach in Java, after all, design patterns like this. Is that if an object $scope.xxx to be called in more than one place, it needs to be made into a singleton object. And in the ANGULARJS, the realization

The simplest way to do this is to call factory () and return the corresponding property method through factory ().

Provide a case for analysis:

<! DOCTYPE html>Create module var app = Angular.module (' myApp ', [' Ngroute ']); Create a factory method instance a common object App.factory (' Todos ', function () {return [{name: ' Mastering Html/css/javascript ', completed:true }, {name: ' Learning AngularJS ', Completed:false}, {name: ' familiar with NodeJS ', completed:true}, {name: ' Contact Express ' JS ', Completed:false}, {name: ' Build MongoDB database ', Completed:false},]})
The routing configuration of App. config ([' $routeProvider ', function ($routeProvider) {$routeProvider. When ('/', {templateurl: ') /todos.html ', controller: ' Todocontroller '). When ('/:id ', {templateurl: '/tododetails.html ', Controller: ' Tododetailcontrl '}]) App.controller (' Todocontroller ', [' $scope ', ' Todos ', function ($scope, Todos) {console.log (' llll '); $scope. Todos = todos}]) App.controller (' Tododetailcontrl ', [' $scope ', ' $routeParams ', ' Todos ', function ($scope, $route Params, Todos) {console.log (' xxx '); $scope. Todo = todos[$routeParams. Id]}]) </script></body>

  

AngularJs Study (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.