Skip to content

Instantly share code, notes, and snippets.

@mbalex99
Created September 3, 2013 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbalex99/6427642 to your computer and use it in GitHub Desktop.
Save mbalex99/6427642 to your computer and use it in GitHub Desktop.
setting and getting the initial value
app = angular.module 'forms', []
app.directive 'ngInitial', ->
restrict: 'A'
controller: ['$scope', '$element', '$attrs', '$parse', ($scope, $element, $attrs, $parse) ->
val = $attrs.sbInitial || $attrs.value
getter = $parse($attrs.ngModel)
setter = getter.assign
setter($scope, val)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment