AngularJS UI router handling 404s

前端 未结 6 1590
粉色の甜心
粉色の甜心 2020-12-03 01:48

I have an app with a service which wraps my API calls:

var ConcernService = {
    ...
    get: function (items_url, objId) {
        var defer = $q.defer();
         


        
6条回答
  •  Happy的楠姐
    2020-12-03 02:26

    I managed to handle 404 without using $urlRoutProvider since I'm only using states by testing $state.transistion:

    angular.module("app", []).run(["$state", "$rootScope", function($state, $rootScope) => {
        $rootScope.$on("$locationChangeSuccess", function() {
            if (!$state.transition) {
                $state.go("404");
            }
        });
    }]);
    

提交回复
热议问题