<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>navbar</title>
????<link?rel="stylesheet"?href="../lib/bootstrap/dist/css/bootstrap.min.css">
????<script?src="../lib/angular/angular.js"></script>
</head>
<body?ng-app="myapp"?ng-controller="ctrl">
????<hello?menu="navs"></hello>
</body>
<script>
?var?app=angular.module("myapp",[]);
????app.controller("ctrl",function?($scope)?{
????????$scope.navs=[
????????????{title:"this?is?first?title",items:["one","two","three"]},
????????????{title:"this?is?second?title",items:["one","two","three"]},
????????????{title:"this?is?third?title",items:["one","two","three"]}
????????]
????})
?app.directive("hello",function?()?{
?return?{
?restrict:"EA",
????????????replace:true,
????????????scope:{
?text:"=menu",
????????????},
????????????template:"<div?ng-repeat='i?in?text'><div>{{i.title}}</div><div?ng-show='showme'?ng-init='showme=true'?ng-repeat='item?in?i.items'>{{item}}</div></div>",
????????????link:function?(scope,?ele,?attr,?ctrl)?{
//????????????????scope.showme=true;
?console.log(scope,ele,attr,ctrl);
????????????}
????????}
????})
</script>
</html>直接上代碼,在這個代碼中ele沒有指向,如何解釋?
關(guān)于angularJs ngRepeat指令的作用域和element問題
qq_Microuncle_0
2016-10-07 21:45:51