关于angularJs ngRepeat指令的作用域和element问题

<!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没有指向,如何解释?

qq_Microuncle_0
浏览 1450回答 1
1回答

李晓健

应该是  replace:true,  新生成的标签把应该指向的标签给替换掉了,所以就没有相应的标签指向了,就只向上ng生成的一行注释。你可以把true改成false试试看看,是不是就指向了相应的标签。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

AngularJS