首先我们使用工具建立一个文件夹名称为ng-repeat。然后在文件夹内建立两个文件分别为index.html,index.js。index.html根据截图编写界面模板。具体如图所示。
然后再index.html引入angularjs文件以及index.js文件。加入两行。分别为:
然后编写index.js。文件。文件内容为:
var app = angular.module("myApp",[]);
app.controller('simpleController',function($scope)
{
$scope.sites = [
{name:'百度',path:'www.baidu.com'},
{name:'新浪',path:'www.sina.com.cn'},
{name:'腾讯',path:'www.qq.com'}
]
});
然后再index.html文件内,定义angularjs的管理域,本篇为从html开始即为angularjs的管理域。然后编写核心处代码,代码为: