Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在AngularJs中动态注册依赖模块_Angularjs_Asp.net Mvc - Fatal编程技术网

在AngularJs中动态注册依赖模块

在AngularJs中动态注册依赖模块,angularjs,asp.net-mvc,Angularjs,Asp.net Mvc,我希望在ASP.NET MVC应用程序的区域内有多个AngularJs模块。每个模块将是一个单独的应用程序。这将帮助我们独立部署每个模块,而无需重建主应用程序。请建议是否可以遵循此方法 我还希望在ASP.NETMVC主应用程序中有index.html页面(在区域部分中有其他SPA)。我想检查如何加载不同的模块,而不在主模块中硬编码(请检查下面的app.js部分) index.html将有ng app='app': <html ng-app='app'> <title/>

我希望在ASP.NET MVC应用程序的区域内有多个AngularJs模块。每个模块将是一个单独的应用程序。这将帮助我们独立部署每个模块,而无需重建主应用程序。请建议是否可以遵循此方法

我还希望在ASP.NETMVC主应用程序中有index.html页面(在区域部分中有其他SPA)。我想检查如何加载不同的模块,而不在主模块中硬编码(请检查下面的app.js部分)

index.html将有ng app='app':

<html ng-app='app'>
<title/>
<body>
<!-- some code -->
</body>
</html>

app.js:

var myApp = angular.module('app', [
    'ngRoute',
    <how to load the dependent modules dynamically with out hard coding them here>`
]);
var myApp=angular.module('app'[
"ngRoute",,
`
]);

我们将非常感谢您的帮助。谢谢

您可以定义一个动态创建依赖项数组的函数

var getDependents = function () {
    var dependents = [];
    dependents.push("ngRoute");
    dependents.push("somethingElse");
    //dynamically add more
    return dependents;
};

var myApp = angular.module('app', getDependents());

您可以定义一个动态创建依赖项数组的函数

var getDependents = function () {
    var dependents = [];
    dependents.push("ngRoute");
    dependents.push("somethingElse");
    //dynamically add more
    return dependents;
};

var myApp = angular.module('app', getDependents());

如果您只想传入配置文件,则可以手动引导应用程序,而不是使用
ng app
如果您只想传入配置文件,则可以手动引导应用程序,而不是使用
ng app