首页 > 代码库 > AngularJS继续中
AngularJS继续中
<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
尚未顿悟
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。