简体   繁体   English

角度指令模板未加载

[英]angular directive template not loading

my angular directive template is not getting loaded into my app. 我的角度指令模板未加载到我的应用中。 The js file for the directive is loading fine except the html. 该指令的js文件可以很好地加载,但html除外。 I checked the 'net' tab in firebug and its not getting called there either. 我检查了萤火虫中的“网络”选项卡,也没有在那里调用它。 I am currently not getting any errors. 我目前没有任何错误。

Here is my directive js: 这是我的指令js:

angular.module('Grid')
.directive('grid', function() {
    return {
        restrict: 'A',
        require: 'ngModel',
        scope: {
            ngModel: '='
        },
        templateUrl: 'scripts/grid/grid.html'
    }
});

Here is my directive 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>

finally here is my index.html where it is meant to go 终于这是我的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>

This has app is being broken up into multiple modules as the new recommended structure for angular 该应用已被分解为多个模块,作为新的推荐结构

grid模块必须是您的twentyApp模块的依赖项。

angular.module('twentyApp', ['grid'])

Are you sure that the Grid module is being loaded? 您确定正在加载Grid模块吗? Try this: 尝试这个:

angular.module('Grid', [])
.directive('grid', function() {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM