且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

角应用程序名称没有确定

更新时间:2023-12-04 12:22:28

这样的回答是基于你是白手创业的角度应用(如 angular.module('对myApp')的假设)在一个单独的<脚本> 文件在您的index.html

This answer is based on the assumption you are bootstrapping your angular app (e.g. angular.module('myApp')) in a separate <script> file in your index.html

您需要确保您的初始角度设置code之前出现其它任何角度&LT;脚本方式&gt; 取值

You need to ensure that your initial angular setup code appears before any other angular <script>s.

<head>
    .....
    <script>
         var myApp = angular.module('myApp', [])
    </script>

    <script src="otherNg.js">
    <script src="anotherNg.js">

一定要引用您的模块中的其他&LT;脚本&GT; 文件正确

为了正确地添加额外的结构到你的对myApp 模块,您需要确保正确地访问它。因为它是在另一个文件中定义的,你需要使用下面的语法来访问它:

be sure to reference your module in other <script> files properly

In order to properly add additional constructs to your myApp module, you need to be sure to access it properly. Since it was defined in another file, you need to use the following syntax to gain access to it:

 var myApp = angular.module('myApp')
 .service("DB_Services", [ .... ])

请注意,这code不包括数组的第二个参数...这是因为这是的的getter 的语法获取已经定义的模块。

Note that this code doesn't include the 2nd parameter of the array... this is because this is getter syntax for getting already defined modules.