【发布时间】:2016-10-04 14:54:13
【问题描述】:
我正在尝试将我的 angularjs 控制器拆分为文件,但每次都失败。
目录结构:
--public--
--js/controller/resturant.js
--js/master.js
--index.php
master.js 的代码
angular.module("rsw",['rsw.controller']);
resturant.js 的代码
angular.module('rsw.controller').controller('resturant', ['$scope', '$http', function($scope, $http){
$scope.data="Test"
}]);
index.php 的代码
--
<div ng-app="rsw">
<span ng-controller="resturant">
{{ data }}
</span>
</div>
--
编辑: 我的 index.php 中只包含了“master.js”,我还需要导入“resturant.js”吗?
【问题讨论】:
-
您已经创建了一个模块“rsw”并在另一个模块“rsw.controller”模块中创建了您的控制器。您是否在 'rsw' 模块中添加了 'rsw.controller' 模块作为依赖项?
-
是的,还是不行
标签: javascript angularjs model-view-controller angularjs-controller