2015-06-24 24 views
1

我有script.js已以下代碼角JS錯誤:該操作是不安全

(function(angular) { 
    'use strict'; 
angular.module('ngViewExample', ['ngRoute', 'ngAnimate']) 
    .config(['$routeProvider', '$locationProvider', 
    function($routeProvider, $locationProvider) { 
     $routeProvider 
     .when('/Book/:bookId', { 
      templateUrl: 'book.html', 
      controller: 'BookCtrl', 
      controllerAs: 'book' 
     }) 
     .when('/Book/:bookId/ch/:chapterId', { 
      templateUrl: 'chapter.html', 
      controller: 'ChapterCtrl', 
      controllerAs: 'chapter' 
     }); 

     $locationProvider.html5Mode(true); 
    }]) 
    .controller('MainCtrl', ['$route', '$routeParams', '$location', 
    function($route, $routeParams, $location) { 
     this.$route = $route; 
     this.$location = $location; 
     this.$routeParams = $routeParams; 
    }]) 
    .controller('BookCtrl', ['$routeParams', function($routeParams) { 
    this.name = "BookCtrl"; 
    this.params = $routeParams; 
    }]) 
    .controller('ChapterCtrl', ['$routeParams', function($routeParams) { 
    this.name = "ChapterCtrl"; 
    this.params = $routeParams; 
    }]); 
})(window.angular); 

和在HTML視圖我有

<div ng-controller="MainCtrl as main"> 
    Choose: 
    <a href="Book/Moby">Moby</a> | 
    <a href="Book/Moby/ch/1">Moby: Ch1</a> | 
    <a href="Book/Gatsby">Gatsby</a> | 
    <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> | 
    <a href="Book/Scarlet">Scarlet Letter</a><br/> 

    <div class="view-animate-container"> 
    <div ng-view class="view-animate"></div> 
    </div> 
    <hr /> 

    <pre>$location.path() = {{main.$location.path()}}</pre> 
    <pre>$route.current.templateUrl = {{main.$route.current.templateUrl}}</pre> 
    <pre>$route.current.params = {{main.$route.current.params}}</pre> 
    <pre>$routeParams = {{main.$routeParams}}</pre> 

也我有book.htmlchapter.html

但它是拋出錯誤,而我點擊任何鏈接。

任何幫助將是非常可觀的

我在角

錯誤堆棧

Error: The operation is insecure. 
Jf/[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:44:436 
[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:104:180 
ef/this.$get</</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:107:221 
hf/this.$get</[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:134:393 
hf/this.$get</[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:131:418 
hf/this.$get</[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:135:158 
ef/this.$get</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:106:46 
Gf/[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:35:70 
e/<()angular.min.js (line 108) 
Ye/this.$get</<()angular.min.js (line 80) 
hf/this.$get</m.prototype.$digest()angular.min.js (line 131) 
hf/this.$get</m.prototype.$apply()angular.min.js (line 135) 
ef/this.$get</<()angular.min.js (line 106) 
Gf/c()angular.min.js (line 35) 
+0

請查看錯誤堆棧 – squiroid

+0

感謝您@squiroid與錯誤堆棧 –

+0

更新我在做什麼錯在這裏 –

回答

0

請在頭相對URL定義基本元素

像新的一樣 - <基地href =「http:// web_directory /」>

在您的應用程序中啓用了html5Mode,因此您應該定義您的網站的基本路徑。

<頭> <基地HREF = 「HTTP:// web_directory /」 > < /頭>

相關問題