voglio AngularJS Cambia percorso senza ricaricare, guarda http://joelsaupe.com/programming/angularjs-change-path-without-reloading/
in Core.js:
'use strict';
angular.module('App',['ngRoute'])
.run(['$route', '$rootScope', '$location', function ($route, $rootScope, $location) {
var original = $location.path;
$location.path = function (path, reload) {
if (reload === false) {
var lastRoute = $route.current;
var un = $rootScope.$on('$locationChangeSuccess', function() {
$route.current = lastRoute;
un();
});
}
return original.apply($location, [path]);
};
}]);
In regolatore:
angular.module('App')
.controller('DetailController', ['$scope', '$location', function($scope) {
$scope.changeURL = function(){
console.log("IN changeURL");
$location.path('/sample/gfshdfdsf', false);
};
}]);
Se invoca changeURL, si verificherà l'errore: ReferenceError: $location is not defined
Qualcuno può aiutarmi? Grazie!
ti ringrazia. Ho cambiato, ma nuovo errore: TypeError: $ location.path non è una funzione. – UNSTABLE
cambia '$ location.path ('/ sample/gfshdfdsf', false);' a '$ location.path ('/ sample/gfshdfdsf');' – sol4me
scusa, $ location.path = function (percorso, ricarica) è definito in .run – UNSTABLE