角度Safari路线参数与空间错误

时间:2016-03-11 03:08:57

标签: angularjs

我的网络应用程序在Chrome,Firefox和IE上工作正常,甚至在iPad Safari浏览器上也可以在Safari桌面上运行 - Windows 7.请参阅下面的代码来触发摘要循环。这仅在空间位于路径参数中时发生,例如如果它包含"测试名称"而不是" TestName"。

错误= [$ rootScope:infdig] 10 $ digest()到达迭代次数。中止!

我不是一个先进的角度程序员,不确定我是否正确编码100%。任何帮助赞赏。感谢。



  app.config(['$routeProvider', '$tooltipProvider', '$locationProvider', '$httpProvider',
  function($routeProvider, $tooltipProvider, $locationProvider, $httpProvider) {
    $httpProvider.useApplyAsync(true);

    var viewBase = '/app/views/';
    $tooltipProvider.options({
      placement: 'bottom',
      popupDelay: '1500'
    });

    $routeProvider
      .when('/', {
        templateUrl: viewBase + 'home.html',
        controller: 'homeController',
      })
      .when('/play/play/:quizName', {
        templateUrl: viewBase + 'quizplay/play.html',
        controller: 'quizPlayController',
        controllerAs: 'vm',
        caseInsensitiveMatch: true,
        resolve: {
          myData: ['crudService', '$route',
            function(crudService, $route) {
              var apiUrl = 'quizApi?quiznameforplay=' + $route.current.params.quizName;
              return crudService.get(apiUrl, '');
            }
          ]
        }
      })
      .otherwise({
        redirectTo: '/',
      });

    $locationProvider.html5Mode(true);
  }
  ]);
  })();


  (function() {
    'use strict';
    app.service('crudService', ['$http',
      function($http) {
        this.get = function(apiUrl, id) {
          if (id != "") apiUrl = apiUrl + "/" + id;

          var headers = {};
          headers.Authorization = 'Bearer ' + sessionStorage.tokenKey;
          var promise = $http({
            method: 'GET',
            url: "/api/" + apiUrl,
            headers: headers
          });
          promise.success(function(data) {
            return data;
          });
          return promise;
        }

        this.delete = function(apiUrl, id) {
          var headers = {};
          headers.Authorization = 'Bearer ' + sessionStorage.tokenKey;
          var request = $http({
            method: "delete",
            url: "/api/" + apiUrl + "/" + id,
            headers: headers
          });
          return request;
        }

        this.put = function(apiUrl, obj) {
          var headers = {};
          headers.Authorization = 'Bearer ' + sessionStorage.tokenKey;
          var request = $http({
            method: "put",
            url: "/api/" + apiUrl,
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify(obj),
            headers: headers
          });
          return request;
        }

        this.post = function(apiUrl, obj) {
          var headers = {};
          headers.Authorization = 'Bearer ' + sessionStorage.tokenKey;
          var request = $http({
            method: "post",
            url: "/api/" + apiUrl,
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify(obj),
            headers: headers
          });
          return request;
        }
      }
    ]);
  })();




0 个答案:

没有答案