Javascript angularjs通过占位符值覆盖ng初始值

Javascript angularjs通过占位符值覆盖ng初始值,javascript,angularjs,angularjs-ng-init,ng-init,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'"/> 它在输入文本区域显示“无响应”,而我想显示占位符值。我怎样才能覆盖它?隐藏ng init值? 谢谢之所以显示“无响应”,是因为输入值为“无响应”。如果要显示

我有以下意见:

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

它在输入文本区域显示“无响应”,而我想显示占位符值。我怎样才能覆盖它?隐藏ng init值? 谢谢

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

不要使用ng init

如果要传递“无响应”而不是null,请在提交时检查条件

例如

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

是的,如果希望ng init值保持为空,只需删除它。仅当输入模型为空时,才会显示占位符。因此,您需要为您的test.response分配“No response”值submit@AnthonyGranger如果没有给出响应,我希望传递ng init值,而不是传递空值。您正在通过
ngInit
设置一个值,您希望保持这种方式,并且想知道如何仍然显示占位符。这就像点热狗,抱怨你想要一个汉堡。我不想删除ng init值,因为我不想在没有响应时传递
null
值。我想通过
无响应
。这就是我选择包含它的原因。在提交表单的函数上,检查this的值是否为null。如果为空,则将值设置为“无响应”