<!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没有指向,如何解释?
李晓健
相关分类