我的HTML:
<input type ="text" ng-model="contactid" >
Run Code Online (Sandbox Code Playgroud)
我想将此框中输入的contactId值传递给在框abc()后面调用onclick提交按钮的函数.
我该怎么做呢?
你可以这样做:
<form ng-controller="formCtrl">
<input type="text" name="name" ng-model="inputValue" />
<button ng-click="abc(inputValue)"></button>
</form>
Run Code Online (Sandbox Code Playgroud)
或者使用ng-submit指令:
<form ng-controller="formCtrl" ng-submit="abc(inputValue)">
<input type="text" name="name" ng-model="inputValue" />
<button type="submit"></button>
</form>
Run Code Online (Sandbox Code Playgroud)
在你的formCtrl控制器中:
.controller('formCtrl', function () {
$scope.inputValue = null;
$scope.abc = function (value) {
console.log(value);
};
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22435 次 |
| 最近记录: |