码迷,mamicode.com
首页 > Web开发 > 详细

AngularJS继续中

时间:2014-07-09 16:55:12      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   art   

<html ng-app>//全局中引用对应于PhoneListCtrl 模板

<head>
    <script src="js/angular.js"></script>
    <script src="js/test.js"></script>
</head>

<body ng-controller="PhoneListCtrl">


    <ul>
        <li ng-repeat="pho in phones">
            {{pho.name}}
            <p>{{pho.snippet}}</p>
        </li>
    </ul>

//div里面的作用域 myapp <div ng-app="myapp" ng-controller="mytest"> <ul> <li ng-repeat="ph in phone"> {{ph.name}} <p>{{ph.snippet}}</p> </li> </ul> </div> </body> </html>

js 代码

function PhoneListCtrl($scope) {
    $scope.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."
      }
    ];
}


//自己声明模板 共外部使用
var app = angular.module(‘myapp‘, []);
app.controller(‘mytest‘, function ($scope) {
    $scope.phone = [
       {
           "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."
       }
    ];
});

http://www.widuu.com/archives/04/1035.html

http://www.ituring.com.cn/article/15762

尚未顿悟

AngularJS继续中,布布扣,bubuko.com

AngularJS继续中

标签:style   blog   http   color   使用   art   

原文地址:http://www.cnblogs.com/yujian-bcq/p/3831913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!