Created
April 17, 2013 06:42
-
-
Save ysyun/5402245 to your computer and use it in GitHub Desktop.
AngularJS의 redirectTo 사용 예
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
$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