我想从不同的指令中读取初始值ngModel.$viewValue.
# coffee script app.directive 'directive',-> return { require: '?ngModel',link: (scope,element,attrs,ngModelCtrl) -> ........ console.log(ngModelCtrl.$viewValue) # does give NaN! ngModelCtrl.$setViewValue('something'); # only after setting reading does work console.log(ngModelCtrl.$viewValue)
我非常感谢任何帮助.
我自己修好了……傻:)
link: (scope,ngModelCtrl) -> scope.$watch(ngModelCtrl,-> console.log(ngModelCtrl.$viewValue) )
确实有用! yippieh!