Skip to content

Instantly share code, notes, and snippets.

@teamon
Created December 19, 2013 16:18
Show Gist options
  • Save teamon/8041904 to your computer and use it in GitHub Desktop.
Save teamon/8041904 to your computer and use it in GitHub Desktop.
Watch state params changes
body body-locker="true"
angular.module("shared").directive "bodyLocker", ($rootScope, $state) ->
link: (scope, element, attrs) ->
$rootScope.$on '$stateChangeSuccess', (event, state) ->
if $state.current.data?.modal
element.addClass("body--locked")
else
element.removeClass("body--locked")
angular.module('HR').config ($stateProvider, $urlRouterProvider, env) ->
$urlRouterProvider.otherwise("/")
$stateProvider
.state('rewards/edit', {
url: "/rewards/edit/:id"
controller: "RewardFormCtrl"
templateUrl: env.templates["hr/rewards/edit.html"]
})
.state('rewards/edit.image', {
templateUrl: env.templates["hr/rewards/_image.html"]
data: { modal: true }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment