日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

angularjs 的模型無法綁定到隱藏域(input hidden)

 昨夜霧濃 2017-11-23

描述一下問題:

在操作表單中的隱藏域的時(shí)候發(fā)現(xiàn)angularjs的模型無法綁定,比如:

<input type="hidden" name="someData" ng-model="data" />

在網(wǎng)上找到了解決辦法,特意記錄;原文:http:///questions/18446359/angularjs-does-not-send-hidden-field-value

這種通常情況下data一直無法取到值;

有以下幾種解決辦法:

1,

<input type="text" name="someData" ng-model="data" style="display: none;"/>

2,

<input type="hidden" required ng-model="data.userid" ng-init="data.userid=pivot.id" />

3,

<input type="hidden" name="someData" value="{{data}}" />

4,

<input type="hidden" name="someData" ng-value="data" />

 

最優(yōu)回答如下:

You cannot use double binding with hidden field. The solution is to use brackets :

<input type="hidden" name="someData" value="{{data}}" /> {{data}}

EDIT : See this thread on github : https://github.com/angular/angular.js/pull/2574

EDIT:

Since Angular 1.2, you can use 'ng-value' directive to bind an expression to the value attribute of input. This directive should be used with input radio or checkbox but works well with hidden input.

Here is the solution using ng-value:

<input type="hidden" name="someData" ng-value="data" />

Here is a fiddle using ng-value with an hidden input: http:///6SD9N

 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多