1

在通过 EJS(javascript)动态加载数学块/模板后,我正在尝试注册/加载控制器:

    logMessage("Rendering " + section + "using the following: templates/blocks/" + pageRegister[pageIdentifier].blocks[section][block] + "/" + block + ".ejs");

    if( blockRegister[block].hasOwnProperty("controller") ){

        //console.log( angular.element(document.getElementById(section)) );
        var b = angular.element(document.getElementById(section));

        b.append(new EJS({
            url: 'templates/blocks/' + pageRegister[pageIdentifier].blocks[section][block] + '/' + block + '.ejs'
        }).render(currentPageData));

        var angularMainCtrl = angular.element(document.getElementById("view-container"));
        //Chrome: undefined
        //Firefox: shows the scope obj of the main app, so what I aspected
        console.log( angularMainCtrl.scope() );

        angularMainCtrl.scope().activateView(angularHtmlCtrlContainer);
    }
    else{
        $('#' + section).append(new EJS({
            url: 'templates/blocks/' + pageRegister[pageIdentifier].blocks[section][block] + '/' + block + '.ejs'
        }).render(currentPageData));
    }

在此刻:

angularMainCtrl.scope().activateView(angularHtmlCtrlContainer);

Chrome 和 Firefox 说

Error: [ng:areq] Argument 'StatusBarController' is not a function, got undefined

我的应用程序:

var myApp = angular.module("myApp", []);

myApp.controller("myController", function($scope, $compile){

     $scope.activateView = function(viewEl){
             $compile(viewEl.contents())($scope);
             $scope.$apply();
     }
});

我在哪里做错了?

4

0 回答 0