AngularJS - how to change the value of ngModel in custom directive?

后端 未结 5 1076
再見小時候
再見小時候 2020-12-23 09:53

Lets take a look to my directive:

angular.module(\'main\').directive(\'datepicker\', [
function() {
    return {
        require: \'?ngModel\',
        link:         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-23 10:08

    This works for a DatePicker on my site

    link: function(scope, elem, attrs, ngModel) {
             scope.$apply(function(){
                 ngModel.$viewValue = value;
             }
    } 
    

提交回复
热议问题