angularjs通过占位符值覆盖ng-init值

时间:2017-01-19 09:22:57

标签: javascript angularjs angularjs-ng-init ng-init

我有以下输入:

<input type="text" placeholder="Enter your response" class="form-control" name="response" ng-model="test.response" ng-init="test.response='No Response'"/>

显示&#34;没有回应&#34;在输入文本区域,而我想显示占位符值。我怎样才能覆盖它?隐藏ng-init值? 感谢

2 个答案:

答案 0 :(得分:2)

不要使用ng-init。

如果您想传递'No Response'而不是null,请检查提交条件

代表

$scope.submitForm = function(){
  if(!test.response){
     test.response='No Response';
  }
}

答案 1 :(得分:1)

它显示“无响应”的原因是因为输入的值是“无响应”。如果要显示占位符,请删除ng-init:)

相关问题