我的角度指令模板没有加载到我的应用程序中。除了html之外,该指令的js文件正在加载。我检查了网络'萤火虫中的标签也没有在那里被调用。我目前没有收到任何错误。
这是我的指令js:
angular.module('Grid')
.directive('grid', function() {
return {
restrict: 'A',
require: 'ngModel',
scope: {
ngModel: '='
},
templateUrl: 'scripts/grid/grid.html'
}
});
这是我的指令html:
<div id="game">
<div class="grid-container">
<div class="grid-cell" ng-repeat="cell in ngModel.grid track by $index"></div>
</div>
<div class="tile-container">
<div tile ng-model="tile" ng-repeat="tile in ngModel.tiles track by $index"></div>
</div>
最后这里是我的index.html,它打算去
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>2048</title>
<link rel="stylesheet" type="text/css" href="styles/game.css" />
<script type="application/javascript" src="scripts/libraries/angularjs.js" ></script>
<script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/game/game.js"></script>
<script type="application/javascript" src="scripts/grid/grid.js"></script>
<script type="application/javascript" src="scripts/grid/grid_directive.js"></script>
</head>
<body ng-app="twentyApp">
<!-- header -->
<div class="container" ng-include="'views/main.html'"></div>
<!-- script tags -->
<div id="game-controller">
<div grid ng-model="ctrl.game" class="row"></div>
</div>
</body>
</html>
这个应用程序被分解为多个模块,作为角度
的新推荐结构答案 0 :(得分:3)
grid
模块需要是twentyApp
模块的依赖项。
angular.module('twentyApp', ['grid'])
答案 1 :(得分:0)
您确定正在加载网格模块吗? 试试这个:
angular.module('Grid', [])
.directive('grid', function() {