$ compile:tpload无法加载模板(自定义模板)

时间:2017-02-07 15:33:53

标签: html angularjs angular-ui-bootstrap

尝试使用自定义模板打开模式时出错。所有文件都在同一个文件夹中。这是我的代码:

noticeModal.html(自定义模式)

<div class="modal-header">
  <h3 class="modal-title" id="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body" id="modal-body">
  I am a modal
</div>
<div class="modal-footer">
  <button type="button" ng-click="vm.ok()">OK</button>
  <button type="button"    ng-click="vm.cancel()">Cancel</button>
</div>

noticeEdit.controller.js(控制器)

(function () {
'use strict';

module.exports = angular
    .module('app.noticeEdit')
    .controller('NoticeEditController', NoticeEditController);

NoticeEditController.$inject = ['$scope', '$uibModal', ];

function NoticeEditController($scope, $uibModal) {

    var vm = this;

    vm.editRow = editRow;

    function editRow(grid, row) {
        $uibModal.open({
            animation: true,
            ariaLabelledBy: 'modal-title',
            ariaDescribedBy: 'modal-body',
            templateUrl: 'noticeModal.html',
            controller: 'NoticeEditController',
            controllerAs: 'vm'
        });
    }
}
})();

noticeEdit.directive.js(指令在哪里是显示模态的按钮)

(function () {
'use strict';

module.exports =  angular
    .module('app.noticeEdit')
    .directive('noticeEdit', noticeEdit);
noticeEdit.$inject = ['$uibModal'];
function noticeEdit($uibModal) {

    var directive = {
        restrict: 'E',
        replace: true,
        transclude: true,
        scope: {
            grid: "<",
            row:  "<"
        },
        link: link,
        controller: 'NoticeEditController',
        controllerAs: 'vm',
        bindToController: true,
        template: "<button type=\"button\" class=\"btn btn-xs btn-primary\" ng-click=\"vm.editRow(grid, row)\"><i class=\"fa fa-edit\"></i></button>"
    };

    return directive;

    function link(scope) {

    }
}
})();

noticeEdit.module.js

module.export = (function () {
'use strict';

angular.module('app.noticeEdit', [
    'ui.bootstrap'
]);

})();

require('./noticeEdit.directive');
require('./noticeEdit.controller');
require('./noticeModal.html');

有没有人知道如何解决这个问题?提前谢谢!

0 个答案:

没有答案