2014-12-29 78 views
0

我使用Angular ui routerhttps://github.com/angular-ui/ui-router)和JSP。我在main.jsp中有我的模板。 JSP使用具有使用JSTL c:foreach循环创建的表行的模板进行呈现。我在我的模板中创建了一个编辑&创建方法。当页面呈现时,我得到下面的异常。AngularJS错误:undefined不是一个对象(评估k.childNodes)使用ui.router

Error: undefined is not an object (evaluating 'k.childNodes') 
[email protected]/js/lib/vendor/angular.min.js:51:223 
<div ui-view="" class="ng-scope"> 

main.jsp中有模板&脚本像下面。我围绕着web Example的一个例子进行了修改。如果你看看route1.list.html,那就是我在main.jsp模板中的内容,除了我的是使用JSTL加载的。我看到来自Angular Team的类似issue。我错过了什么。但是一旦我从SPAN元素中删除ng-click,我就看不到错误。

<div class="content"> 
    <div ui-view></div> 
</div> 

<!-- Templates below --> 
<script id="ports.html" type="text/ng-template"> 
<div> 
<button name="create" value="create" ng-click="createPort()">test</button> 
<table> 
    <thead> 
    <tr> 
     <th>Name</th> 
     <th>Port</th> 
    </tr> 
    </thead> 
    <tbody> 
    <c:forEach items="${MyForm.portsList}" var="port"> 
     <tr> 
      <td>${port.name} <p>${port.description}</p></td> 
      <td><span ng-click="editPort()">${port.id}</span></td> 
     </tr> 
    </c:forEach> 
    </tbody> 
</table> 
</div> 
</script> 
<script> 
    var app = angular.module('MyApp',["ui.router","ui.bootstrap"]); 
    app.config(function($stateProvider, $urlRouterProvider){ 
    $stateProvider 
    .state('ports', { 
     url: "/ports", 
     templateUrl: "ports.html", 
     controller: PortsCtrl 
     }) 

    $urlRouterProvider.otherwise("/ports") 
    }) 

    function PortsCtrl($scope){ 
    $scope.editPort = function(){ 
     console.log("Show ports clicked!); 
    } 
    $scope.createPort = function(){ 
     console.log("Show ports clicked!); 
    } 
} 
</script> 

回答

0

正好碰上这个问题,
所以我你的代码比较雷。

在我看来,这是HTML说明的原因。
所以只是删除这个<!-- Templates below -->

我会很高兴知道它是否适合你。

相关问题