【发布时间】:2015-01-08 04:38:16
【问题描述】:
这是一个非常愚蠢的问题,但我一直在为此苦苦挣扎,希望有人能提供帮助。
在创建我的 Angular 应用程序时,我知道为了注入正确的提供程序,我首先需要在定义我的模块时包含它/需要它。
这里是一个例子——这里我需要 $routeProvider,所以我包含了 ngRoute:
var sampleApp = angular.module('phonecatApp', ['ngRoute']);
sampleApp.config(['$routeProvider',
function ($routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider.
when('/about', {
templateUrl: 'home/about',
controller: 'AddOrderController'
}).
when('/contact', {
templateUrl: 'home/contact',
controller: 'ShowOrdersController'
}).
otherwise({
redirectTo: '/about'
});
}]);
现在我还需要 $locationProvider 但不知道要包含什么模块,我查看了所有 angularjs 文档并尝试 ngLocation 但没有运气!我的问题(不是我需要哪个模块来定位),而是如何从角度文档中找出任何给定提供者需要哪个模块?
我无法从疯狂的文档中弄清楚?
var sampleApp = angular.module('phonecatApp', ['ngRoute', '?????']);
sampleApp.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.
when('/about', {
templateUrl: 'home/about',
controller: 'AddOrderController'
}).
when('/contact', {
templateUrl: 'home/contact',
controller: 'ShowOrdersController'
}).
otherwise({
redirectTo: '/about'
});
}]);
【问题讨论】:
标签: angularjs