Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Set model value to given form value in html
app.directive 'ngInitial', ->
restrict: 'A'
controller: ['$scope', '$element', '$attrs', '$parse', ($scope, $element, $attrs, $parse) ->
val = $attrs.sbInitial || $attrs.value || $element.text()
getter = $parse($attrs.ngModel)
setter = getter.assign
setter($scope, val)

fjsj commented Oct 13, 2014

sbInitial in line 4 shouldn't be ngInitial?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment