更新时间:2023-02-18 22:23:14
几件事情:
1 require.config
***应放置在 main.js
并装载在你的 index.html的
使用:
1. require.config
should ideally be placed inside a main.js
and loaded in your index.html
using:
<script data-main="js/main.js" src=".../require.js"></script>
2 尝试在你的路线来定义控制器,并删除 NG-控制器
home.html的:
2. Try to define controller in your route and remove ng-controller
home.html:
...
$routeProvider.when('/home', {
templateUrl: 'views/home.html',
controller: 'HelloWorld', // <-- Need to add this line
...
3 您home.js应该使用定义
而不是要求
作为你在这里定义的模块。
3. Your home.js should be using define
instead of require
as you are defining a module here.
我创建了以下项目,以方便使用RequireJS和AngularJS的,你应该看一看:结果
https://github.com/marcoslin/angularAMD
I created the following project to facilitate the use of RequireJS and AngularJS that you should take a look:
https://github.com/marcoslin/angularAMD