Skip to content

Instantly share code, notes, and snippets.

@ysyun
Created April 17, 2013 06:42
Show Gist options
  • Save ysyun/5402245 to your computer and use it in GitHub Desktop.
Save ysyun/5402245 to your computer and use it in GitHub Desktop.
AngularJS의 redirectTo 사용 예
/*
$routeProvider의 redirectTo 사용하기
<div ng-app="app">
<ng-view></ng-view>
</div>
*/
var app = angular.module("app", []);
app.config(function($routeProvider) {
$routeProvider.when('/map/:country/:state/:city',
{
templateUrl: "app.html",
controller: "AppCtrl"
}
)
.when('/pizza/:crust/:toppings', {
redirectTo: function(routeParams, path, search){
console.log(routeParams);
console.log(path);
console.log(search);
return "/" + routeParams.crust
}
})
.when("/deep", {
template: "Deep dish"
})
.otherwise({
redirectTo: "/"
})
})
app.controller("AppCtrl", function($scope, $routeParams) {
$scope.model = {
message: "Address: " + $routeParams.country +
", State: " + $routeParams.state +
", City: " + $routeParams.city
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment