Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs-选择元素(textarea)并更改其值_Angularjs - Fatal编程技术网

Angularjs-选择元素(textarea)并更改其值

Angularjs-选择元素(textarea)并更改其值,angularjs,Angularjs,有人能告诉我怎么做吗?我的解决方案都不管用 我是Angularjs的新手,提前感谢您的耐心。我想这就是您想要的 myApp = angular.module("myApp",[]); 控制器(“myController”,函数($scope){ $scope.textAreaValue=“你好世界” })) 要获得完整的代码,你可以去伙计!粘贴一些代码或尝试解释更多!为了修改输入元素,您似乎使用了jquery-ish方法,这在angularJS范例中是非常糟糕的。就像任何输入一样,使用ng m

有人能告诉我怎么做吗?我的解决方案都不管用


我是Angularjs的新手,提前感谢您的耐心。

我想这就是您想要的

myApp = angular.module("myApp",[]);
控制器(“myController”,函数($scope){ $scope.textAreaValue=“你好世界”

}))


要获得完整的代码,你可以去

伙计!粘贴一些代码或尝试解释更多!为了修改输入元素,您似乎使用了jquery-ish方法,这在angularJS范例中是非常糟糕的。就像任何输入一样,使用ng model directive属性并从控制器设置$scope。我故意不添加任何代码,因为我是“面向jquery”的,我认为必须有更多的“面向角度”解决方案,如@chandings所述。谢谢@chandings,这充分解释了这一点。这称为数据绑定吗?是的,我们将“$scope.textAreaValue”绑定到文本区域的ng模型。ng模型是一个内置指令,用于将值绑定到各种输入。在angularjs中,您将大量使用ng模型。ng更改、ng焦点和ng模糊也是内置的角度指令。
$scope.textAreaChanged = function(){
    console.log("textAreaChanged new value> " + $scope.textAreaValue);
}

$scope.textAreaBlurred = function(){
    console.log("textAreaBlurred");
}

$scope.textAreaFocussed = function(){
    console.log("textAreaFocussed");
}