首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >角js错误:操作不安全

角js错误:操作不安全
EN

Stack Overflow用户
提问于 2015-06-24 13:08:42
回答 1查看 2.4K关注 0票数 1

我有script.js,它有以下代码

代码语言:javascript
运行
复制
(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视图中,我有

代码语言:javascript
运行
复制
<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

但当我单击任何链接时,它会抛出错误。

任何帮助都将是非常可观的。

我是新来的

错误堆栈

代码语言:javascript
运行
复制
Error: The operation is insecure.
Jf/l.url@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:44:436
h@https://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</m.prototype.$eval@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:134:393
hf/this.$get</m.prototype.$digest@https://ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js:131:418
hf/this.$get</m.prototype.$apply@https://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/c@https://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)
EN

回答 1

Stack Overflow用户

发布于 2017-01-21 03:22:49

请用相对Url在head中定义基元素

就像-

在您的应用程序中启用了html5Mode,因此您应该定义网站的基本路径。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31027496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档