[Angular-Scaled web] 5. ui-router $stateParams for sharing information

When using ui-route, we want to pass the information with the url.

Example:

angular.module('categories.bookmarks', [
'categories.bookmarks.create',
'categories.bookmarks.edit',
'eggly.models.categories',
'eggly.models.bookmarks'
]) .config(function ($stateProvider) {
$stateProvider
.state('eggly.categories.bookmarks', {
url: 'categories/:category',
views: {
'bookmarks@': {
controller: 'BookmarksController',
templateUrl: 'app/categories/bookmarks/bookmarks.tmpl.html'
}
}
}) }) .controller('BookmarksController', function ($scope, $stateParams) { $scope.currentCategory = $stateParams.category;
$scope.stateParams = $stateParams;
})
;

Using :category to pass the params in url. And we can get the params in Controller by using $stateParams.

[Angular-Scaled web] 5. ui-router $stateParams for sharing information

上一篇:通过USB转TTL串口下载stm32程序


下一篇:[整] Android Fragment 生命周期图