Skip to main content
added 2 characters in body
Source Link
David Wolever
  • 155.8k
  • 94
  • 365
  • 513

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeStart""$stateChangeSuccess", function updatePage() { $scope.page = $state.params.slug; }); }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeStart", function updatePage() { $scope.page = $state.params.slug; }); }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeSuccess", function updatePage() { $scope.page = $state.params.slug; }); }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

deleted 71 characters in body
Source Link
Myk
  • 6.2k
  • 4
  • 30
  • 33

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeStart", updatePage); function updatePage() { $scope.page = $state.params.slug; } updatePage(); // call it once to initialize.  }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeStart", updatePage); function updatePage() { $scope.page = $state.params.slug; } updatePage(); // call it once to initialize. }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeStart", function updatePage() { $scope.page = $state.params.slug; });   }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

added 1 character in body
Source Link
David Wolever
  • 155.8k
  • 94
  • 365
  • 513

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.on$on("$stateChangeStart", updatePage); function updatePage() { $scope.page = $state.params.slug; } updatePage(); // call it once to initialize. }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.on("$stateChangeStart", updatePage); function updatePage() { $scope.page = $state.params.slug; } updatePage(); // call it once to initialize. }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

I would do something like this:

.controller("PageCtrl", function($scope, $state) { $scope.$on("$stateChangeStart", updatePage); function updatePage() { $scope.page = $state.params.slug; } updatePage(); // call it once to initialize. }); 

I'd be curious if you find a better way - there may be some way to just watch the value of the state slug, but this is clean and clearly articulates what it is that you're watching for.

added 7 characters in body
Source Link
Myk
  • 6.2k
  • 4
  • 30
  • 33
Loading
Source Link
Myk
  • 6.2k
  • 4
  • 30
  • 33
Loading