Passing model to function does not really make sense since you have already specified ng-model
, so it's value will be updated as user types something into the textbox
. If you want to track changes you can setup a $watch
for your model or specify a function using ng-change
.
If you want to know what user pasted, then that's another story. Handling ng-paste
can be tricky. To access the actual event, easiest is to include jQuery
before angularjs
and then do e.g. following:
HTML template
<textarea rows="3"
placeholder="copy/paste here..."
ng-init="content = null"
ng-model="content"
ng-paste="paste($event.originalEvent)">
</textarea>
Controller
$scope.paste = function (event) {
var item = event.clipboardData.items[0];
item.getAsString(function (data) {
console.log(data);
});
};
Related plunker here http://plnkr.co/edit/ea5y5j