
- restrict 约束,限制
- template 模版
<script>
var myModel=angular.module("myApp",[]);
myModel.controller("helloAngular",['$scope',function($scope){
$scope.mygressting={
text:'hello'
};
}]);
myModel.directive("hello",function(){
return{
restrict:'E',
template:'<div>Hi everyOne</div>div',
replace:true
}
})
</script>
- 关于ng-repeat 删除
$index是传入的第几个
<body ng-app="myApp" ng-controller="myController" >
<div>{{name}}</div>
<div ng-repeat="item in items">
<span>{{item.price}}</span>
<input type="text" ng-model="item.price"/>
<button ng-click="remove($index)">remove</button>
</div>
<script>
var app=angular.module("myApp",[]);
app.controller('myController',function($scope){
$scope.name="zhanger";
$scope.items=[
{title:'nihao',price:12345},
{title:'jeje',price:456}
];
$scope.remove=function(num){
console.log(num);
$scope.items.splice(num,1);
};
})
</script>
</body>