angularjs教程

当前位置:首页>AngularJS>angularjs教程>AngularJS - Mobile Nav - How to install other Controller

AngularJS - Mobile Nav - How to install other Controller

时间:2015-06-27 15:54来源:网络整理 作者:KKWL 点击:
I have Probleme with the Controller. Can you help me with this code? I have the Plugin of the Site: the first module does not work :/ I would like to include this code of "MainCtrl" in the controller: var roomcatApp = angular.module('roomca

I have Probleme with the Controller. Can you help me with this code? I have the Plugin of the Site: the first module does not work :/

I would like to include this code of "MainCtrl" in the controller:

var roomcatApp = angular.module('roomcatApp', [ 'ngRoute', 'roomcatControllers', 'roomcatFilters', 'roomcatServices' ]); roomcatApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/rooms', { templateUrl: 'partials/room-list.html', controller: 'RoomListCtrl' }). when('/rooms/:roomId', { templateUrl: 'partials/room-detail.html', controller: 'RoomDetailCtrl' }). when('/rooms/:roomId/map', { templateUrl: 'partials/room-list.html', controller: 'MapCtrl' }). otherwise({ redirectTo: '/rooms' }); }]); angular.module('roomcatApp', ['snap']) .controller('MainCtrl', function ($scope) { $scope.snapOpts = { disable: 'right' }; });

or do I add this part here?

var roomcatControllers = angular.module('roomcatControllers', []); roomcatControllers.controller('RoomListCtrl', ['$scope', 'Room', function($scope, Room) { $scope.rooms = Room.query(); $scope.orderProp = 'age'; }]); roomcatControllers.controller('RoomDetailCtrl', ['$scope', '$routeParams', 'Room', function($scope, $routeParams, Room) { $scope.room = Room.get({roomId: $routeParams.roomId}, function(room) { $scope.mainImageUrl = room.images[0]; }); $scope.setImage = function(imageUrl) { $scope.mainImageUrl = imageUrl; } }]); roomcatControllers.controller('MapCtrl', ['$scope', '$routeParams', 'Room', function($scope, $routeParams, Room) { $scope.rooms = Room.query(); $scope.room = Room.get({roomId: $routeParams.roomId}, function(room) { $scope.mainImageUrl = room.images[0]; }); }]);

我没问题的控制器。你能帮我写这个代码吗?我有网站的插件:第一个模块不工作:/

我想包括“MainCtrl”控制器的这段代码:

var roomcatApp = angular.module('roomcatApp', [ 'ngRoute', 'roomcatControllers', 'roomcatFilters', 'roomcatServices' ]); roomcatApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/rooms', { templateUrl: 'partials/room-list.html', controller: 'RoomListCtrl' }). when('/rooms/:roomId', { templateUrl: 'partials/room-detail.html', controller: 'RoomDetailCtrl' }). when('/rooms/:roomId/map', { templateUrl: 'partials/room-list.html', controller: 'MapCtrl' }). otherwise({ redirectTo: '/rooms' }); }]); angular.module('roomcatApp', ['snap']) .controller('MainCtrl', function ($scope) { $scope.snapOpts = { disable: 'right' }; });

或者我添加这部分吗?

var roomcatControllers = angular.module('roomcatControllers', []); roomcatControllers.controller('RoomListCtrl', ['$scope', 'Room', function($scope, Room) { $scope.rooms = Room.query(); $scope.orderProp = 'age'; }]); roomcatControllers.controller('RoomDetailCtrl', ['$scope', '$routeParams', 'Room', function($scope, $routeParams, Room) { $scope.room = Room.get({roomId: $routeParams.roomId}, function(room) { $scope.mainImageUrl = room.images[0]; }); $scope.setImage = function(imageUrl) { $scope.mainImageUrl = imageUrl; } }]); roomcatControllers.controller('MapCtrl', ['$scope', '$routeParams', 'Room', function($scope, $routeParams, Room) { $scope.rooms = Room.query(); $scope.room = Room.get({roomId: $routeParams.roomId}, function(room) { $scope.mainImageUrl = room.images[0]; }); }]);

------分隔线----------------------------