Angular JS

最近有点时间,想系统的学习下angular.会把要做笔记的地方记录下,方便以后查询。

Part 1.

对于一个index.html

包括三部分

  1. ng-app = "phonecatApp" 定义了作用域

  2. ng-controller = "PhoneListController" 定义了controller

  3. ng-repeat = "phone in phones" 定义了实现

对于app.js

 1.var phonecatApp = angular.module('phonecatApp',[]); 定义phonecatApp module

 2. phonecatApp.controller ('PhoneListController', function PhoneListController($scope) {

  $scope.phones =[...];

}

 

tips:

a.ng-repeat = "phone in phones | filter:query" 用来做fitler

index.html -> define  <phone-list></phone-list>

In app.module.js

'use strict';

// Define the `phonecatApp` module
angular.module('phonecatApp', [
  // ...which depends on the `phoneList` module
  'phoneList'
]);

In phone-list.module.js


'use strict';

// Define the `phoneList` module
angular.module('phoneList', []);

In phone-list.component.js

'use strict';

// Register `phoneList` component, along with its associated controller and template
angular.
  module('phoneList').
  component('phoneList', {
    templateUrl: 'phone-list/phone-list.template.html',
    controller: function PhoneListController() {
      this.phones = [
        {
          name: 'Nexus S',
          snippet: 'Fast just got faster with Nexus S.'
        }, {
          name: 'Motorola XOOM™ with Wi-Fi',
          snippet: 'The Next, Next Generation tablet.'
        }, {
          name: 'MOTOROLA XOOM™',
          snippet: 'The Next, Next Generation tablet.'
        }
      ];
    }
  });

 

posted @ 2016-11-22 13:51  helloCZ  阅读(210)  评论(0编辑  收藏  举报