最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Enabling html 5 mode for Angular JS throws JS error: Failed to instantiate module due to: TypeError: Cannot read pr

programmeradmin0浏览0评论

How can I enable html 5 mode for Angular JS?

'use strict'

var blogApp = angular.module('blogApp', ['ngRoute'])
    .config(['$routeProvider', function ($routeProvider, $locationProvider) {
    $routeProvider.when('/disclaimer', { templateUrl: 'templates/disclaimer.html', controller:         'DisclaimerCtrl' });
    $routeProvider.otherwise({ redirectTo: '/' });
    $locationProvider.html5Mode(true);
}]);

When I add the line about html5mode, I get the following JS error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to:

TypeError: Cannot read property 'html5Mode' of undefined

I'm using Angular 1.2.15 on IIS

How can I enable html 5 mode for Angular JS?

'use strict'

var blogApp = angular.module('blogApp', ['ngRoute'])
    .config(['$routeProvider', function ($routeProvider, $locationProvider) {
    $routeProvider.when('/disclaimer', { templateUrl: 'templates/disclaimer.html', controller:         'DisclaimerCtrl' });
    $routeProvider.otherwise({ redirectTo: '/' });
    $locationProvider.html5Mode(true);
}]);

When I add the line about html5mode, I get the following JS error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to:

TypeError: Cannot read property 'html5Mode' of undefined

I'm using Angular 1.2.15 on IIS

Share Improve this question asked May 11, 2014 at 15:21 HoppeHoppe 6,81518 gold badges64 silver badges122 bronze badges 1
  • $locationProvider is not declared in injections list (in config(), before function declaration). – user680786 Commented May 11, 2014 at 15:31
Add a comment  | 

1 Answer 1

Reset to default 20

config(['$routeProvider', is missing $locationProvider declaration on the array.

.config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider) {

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论