gpt4 book ai didi

javascript - AngularJs ng-model substr

转载 作者:太空狗 更新时间:2023-10-29 14:07:53 25 4
gpt4 key购买 nike

如何在没有 ng-model 首字母的情况下设置输入值。我不想改变模型值本身。只是输入的内容没有首字母。

<input type="text" ng-model="myVal" >

和js

$scope.myVal = 'Hello';

想要的结果:你好

最佳答案

假设您不想要双向数据绑定(bind),您可以使用 value 而不是 ng-model

<input type="text" value="{{myVal.substr(1)}}" >

如果你确实想要双向数据绑定(bind),在模型语句上使用 substr 是没有意义的。

关于javascript - AngularJs ng-model substr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35140504/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com