我试图在输入文本中插入值:
Angular JS:
$scope.pasteYoutube = function (){
$timeout(function () {
// get $scope.url from input
});
}
HTML:
<input ng-paste="pasteYoutube()" ng-trim="true" ng-model="url" type="text" class="long-input">
但我得到underfined $scope.url
答案 0 :(得分:0)
我的猜测是角度尚未处理输入。尝试添加超时值,默认值为0,以便立即执行该功能。
编辑:
变化
$timeout(function () {
// get $scope.url from input
});
到
$timeout(function () {
// get $scope.url from input
}, 10);
这将等待10毫秒让angular从输入中获取url。