更新时间: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
模块,您需要确保正确地访问它。因为它是在另一个文件中定义的,你需要使用下面的语法来访问它:
<script>
files properlyIn 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.