Skip to content

wowissu/angular-model-init

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

angular-model-init

init ng-model

Example

<input ng-model="myModel" ng-model-init="'123456'" />
<input ng-model="myModel" ng-model-init="[1, 2, 3]" />
<input ng-model="myModel" ng-model-init="myVar" />

Directive

app.directive('ngModelInit', ['$parse', function ($parse) {
    return {
        require: '?ngModel',
        restrict: 'A',
        link: function ($scope, $element, $attrs, ngModel) {
            if (!ngModel) {
                return;
            }
            ngModel.$setViewValue($parse($attrs.ngModelInit)($scope));
            ngModel.$render();
        }
    };
}]);

About

initialize ng-model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published