typeError:无法读取角度js中未定义的属性“childNodes”

时间:2016-05-18 06:58:41

标签: jquery angularjs

我在angularjs中遇到问题,当我尝试执行此代码时,它返回给我TypeError:无法读取未定义的属性'childNodes'。

这是我的代码: 的的index.html

<!doctype html>
<html ng-app="myApp">
<head>
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="css/materialize.css">
<link rel="stylesheet" href="css/materialize.min.css">
<link rel="stylesheet" href="css/custom.css"> 

<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular-route.min.js"></script>
<script src="js/angular-messages.js"></script>
<script src="js/materialize.js"></script>
<script src="js/materialize.min.js"></script>
<script src="services/app.js"></script>
<script src="services/controllers.js"></script>
<script src="services/common/services.js"></script>
<script src="services/oliveService.js"></script>

<title>Task Managment System</title>
</head>
<body ng-view>

</body>
<h1>{{message}}</h1>
</body>
</html>

app.js

angular.module('myApp', ['ngRoute','myApp.services','myApp.controllers'])

.config(function($routeProvider) {
$routeProvider

   .when('',{
   })

   .when('/blah', {
     title: 'Blah',
     templateUrl : 'templates/blah.html'
   })
   .otherwise({redirectTo: '/login'}); 
})

.directive('header', function () {
 return {
    replace: true,
    templateUrl: "templates/header.html",
    controller: "HeaderCtrl" 
 }
})

当我从指令中删除templateURl然后它工作正常但我需要从模板调用此指令内容。

controller.js

.controller('HeaderCtrl', function($scope, $http){
    console.log('Header controller called');
    //$(".dropdown-button").dropdown();
})

当我也评论jquery线时,它的工作原理。这用于标题

中的下拉内容

header.html中

 <div>
     <ul id="dropdown1" class="dropdown-content">
         <li><a href="javascript:void(0)" ng-click="logout()">logout</a></li>
         <li><a href="javascript:void(0)" ng-click="call_page('account')">Setting</a></li>
     </ul>
     <nav>
          <div class="nav-wrapper">
          <a href="javascript:void(0)" class="brand-logo">Timetrack</a>
          <ul class="right hide-on-med-and-down">
              <li>
                  <a class="dropdown-button" href="#!" data-activates="dropdown1">{{email | capitalize}}
                  <i class="material-icons right">arrow_drop_down</i></a>
              </li>
         </ul>
         </div>
     </nav>
</div>
在header.html中有很多代码,但在这里我只打印了一些代码。 我需要在其他页面中应用此header指令,如

blah.html

<div header></div>
<div>
    <h1> this is blah </h1>
</div>

0 个答案:

没有答案