javascript - Route with multiple modules an inline views not working - $http interceptor possibly causing errors -
i'm working in project angular.
the idea have different modules , each 1 of them able register own routes. partials within same html inline. not working...
here plunkr http://plnkr.co/edit/n3q1fw95ld24xqtf37az
the code like:
<body ng-class="{loaded: loaded}" ng-app="stream" ng-controller="streamctrl"> <div id="wrapper" ng-show="loaded"> <div ng-view></div> </div> <script type="text/ng-template" id="welcome.html"> template </script> </body>
and js:
(function() { "use strict"; angular.module("default", ["ngroute"]) .config( ["$httpprovider", "$routeprovider", "$locationprovider", function ($httpprovider, $routeprovider, $locationprovider) { $routeprovider .when("/mee", { templateurl: "partials/welcome.html" }) .when("/mee/index", { templateurl: function(params){ console.log("getting partial url"); return "partials/welcome.html" } }) ; } ]) ; })(); (function() { "use strict"; angular.module("stream", [ "default" ]) .config(["$locationprovider", function($locationprovider) { }]) .run(function($rootscope, $log, $window) { $log.info("setting application status loaded!"); $rootscope.loaded = true; }); })();
the full code not working can seen in plunkr...
finally able find answer...
turns out, requests templates (even if cached) affected $http interceptors.
the plunkr working here:
http://plnkr.co/edit/rouhkigp9rzcfuc6pc3v?p=preview
this interceptor affecting resolving of data.
$httpprovider.interceptors.push(function($q) { return { 'response': function(response) { return response.data; }, 'responseerror': function(rejection) { return $q.reject(rejection); } }; });
i still need interceptor. this:
$httpprovider.interceptors.push(function($q) { return { 'response': function(response) { if (response.config.method == "get" && response.config.url.split(".").pop() == "html") return response; return response.data; }, 'responseerror': function(rejection) { return $q.reject(rejection); } }; });
thanks https://stackoverflow.com/a/25060769/1339973 provide solution problem $http interception when template
Comments
Post a Comment