在控制器中加载时,指令,链接功能不会触发

时间:2015-12-06 07:14:20

标签: javascript angularjs controller directive

我尝试加载" emailTemplatebuilder"指令用于" emailtemplatebuilderController"控制器。

控制器代码:

'use strict';

define('emailtemplatebuilderController', ['app', 'emailTemplatebuilder', 'servicebase', ], function (app, emailTemplatebuilder, servicebase) {
app.lazy.controller('emailtemplatebuilderController', [
    "$scope", '$routeParams', "$cookies", 'sharedServices', 'servicebase', '$location', function ($scope, $routeParams, $cookies, sharedServices, servicebase, $location) {

        debugger;



    }]);
});

和指令:

'use strict';

define('emailTemplatebuilder', ['app'], function (app) {
debugger;
app.directive('templatedirective', ['$rootScope',  function (rootscope) {
    return {
        restrict: 'AE',
        link: function (scope, element, attributes) {

            debugger;

        }
    }
}]);
});

在这种情况下,链接功能不会触发。但是当我在requirejs配置文件中的require部分加载指令时,如下所示:

require.config({
baseUrl: window.baseUrl, //'/app',
urlArgs: 'v=1.0',
skipDataMain: true,

paths: {
...
},
 shim: {
    ...
},
require(
[
'jquery', 'jqueryUi',
'angular', 'angularAnimate',
'angularUiBootstrap',
'app',
'emailTemplatebuilder'
],
function (PNotify) {
    angular.bootstrap(document, ['app']);

});

和指令:

'use strict';

define('emailtemplatebuilderController', ['app', 'servicebase', ], function (app,  servicebase) {
app.lazy.controller('emailtemplatebuilderController', [
    "$scope", '$routeParams', "$cookies", 'sharedServices', 'servicebase', '$location', function ($scope, $routeParams, $cookies, sharedServices, servicebase, $location) {

        debugger;

    }]);
});

然后它的工作原理。第一种情况出了什么问题?

更新:

我在html中使用的方式

<div ng-controller="emailtemplatebuilderController">
<div templatedirective></div>
</div>

0 个答案:

没有答案