AngularJS模块不起作用

巴斯蒂安·安德里森(Bastiaan Andriessen)

所以我一直在研究这个问题太久了。真的希望有人能帮助我:)我只是试图创建一个模块,该模块为AngularJS中的网站标头创建指令和控制器。我没有任何错误,我的代码中的日志也不会显示。这是与头模块相关的代码:

header / header.js

 'use strict';
angular.module('myApp.header', [])

.directive("headerBar", [function(){
  return {
    restric: "E",
    templateUrl: "header/header.html",
    controller: 'HeaderCtrl'
  };
}])

.controller('HeaderCtrl', ['$log', function($log) {
  $log.log('test header controller');
}]);

app.js

angular.module('myApp', [
  'ngRoute',
  'myApp.header'
]).
config(['$routeProvider', function($routeProvider) {
  $routeProvider.otherwise({redirectTo: '/'});
}]);

index.html

<script src="header/header.js"></script>


<header-bar></header-bar>
马特·狄奥尼斯

我看到您的指令定义有错字:

  • 应该是restrict: "E",您目前缺少't'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章