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.'
        }
      ];
    }
  });

 

转载于:https://www.cnblogs.com/hellocz/p/6088965.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值