1. 程式人生 > >angular應用,一個input上有自定義directive和ng-model,怎麼在directive更新input的value時更新model

angular應用,一個input上有自定義directive和ng-model,怎麼在directive更新input的value時更新model

https://segmentfault.com/q/1010000000347476

wise.directive('upload', function ($parse) {
    return {
        link: function ($scope, iElement, iAttrs, controller) {
            iElement.upload({
                success: function(data, self) {
                    $parse(iAttrs['ngModel']).assign($scope, data);
                    $scope.$apply();
                },
            });
        }
    };
});