我想在1个js文件中定义2个控制器(读取2个json)。并使用pug文件从2 json回调数据。我的代码如下:
angular.module('shop-menu.controller', []).controller("Shop-menuController", _shopmenuController)
function _shopmenuController($scope, $http) {
$http({
method: 'GET', // POST, PUT, DELETE
url: '../db/shop-menu.json',
}).then(function (response) {
$scope.data = eval(response.data.data);
}, function (error) {
console.log('error 003 - Shop: ' + error);
});
// $scope.loadlist = function(){
// console.log("1")
// }
}
function _shopController($scope, $http) {
$http({
method: 'GET', // POST, PUT, DELETE
url: '../db/shop-list.json',
}).then(function (response) {
$scope.data = eval(response.data.data);
}, function (error) {
console.log('error 003 - Shop: ' + error);
});
}
pug文件:
.row(ng-controller="_shopmenuController")
ul.list-inline(ng-repeat="phuong in data")
li(ng-click="loadlist")
a.nav-link {{phuong.name}}
.row(ng-controller="_shopController")
ul.list-inline(ng-repeat="tam in data")
li(ng-click="loadlist")
a.nav-link {{tam.name}}
请帮助我! 谢谢