The way of AngularJS learning

Source: Internet
Author: User

AngularJS extends HTML through ng-directives .

The ng-app directive defines an AngularJS application. Which is the entrance of the ANGULARJS function in what label or whole body inside

The ng-model directive binds the application data to the HTML controller (input, select, textarea) by binding the value of the element (such as the value of the input field). Two-way binding

The ng-bind directive binds the application data to an HTML view. More used to display content common span labels

The ng-init directive initializes the AngularJS application variable. Define initial values, generally not used

The ng-repeat instruction repeats an HTML element. Multiple traversal for arrays

The ng-controller directive defines the application controller. Using $scope object to invoke the controller, adding properties and methods to $scope in the controller can call the property or method directly in the Ng-model , $scope must write

Instructions

Custom directives: Take advantage of the directive command. For example:

var app = Angular.module ("myApp", []);
App.directive ("runoobdirective", function () {
return {
Restrict: "A",
Template: "};
});

Call the custom command to use the name of the custom command as the attribute class name (comment, label), but you can set the invocation method by restrict

    • EUse as an element name is not recommended
    • AUse as attribute
    • CRecommended for use as a class name
    • MUse as a comment is not recommended

Service

$location Get the URL of the page you need to $location as the controller parameters

$http request to the server to obtain data needs to take $http as parameters of the controller

var app = Angular.module (' myApp ', []);
App.controller (' Myctrl ', function ($scope, $http) {
$http. Get ("welcome.htm"). Then (function (response) {
$scope. mywelcome = Response.data;
});
});

How long does $timeout delay Execute

How often do $interval Execute

Custom Service: Invoking the server command

App.service (' alert ', function () {
alert (' Server ')
});

After the call is defined, the name of the custom service needs to be added to the controller's parameters.

The way of AngularJS learning

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.