Javascript AngularJS ng重复:视图不';t更新型号变更…;

Javascript AngularJS ng重复:视图不';t更新型号变更…;,javascript,angularjs,Javascript,Angularjs,我正试图通过ng submit将项目添加到我的视图中。函数getTemp按预期工作,并且$scope.temperatures已正确更新(我可以在控制台中看到),但是新的数据值不会出现在视图中。我不确定什么东西没有正确绑定 我已经看过了其他相关的问题,但没有一个是完全相同的 视图: 问题是表单中有ng controller=“tempCtrl”。这将创建其自己的当前作用域的子作用域。因此,放入此范围的任何对象都不会影响当前范围。尝试删除它: <div ng-controller="tem

我正试图通过ng submit将项目添加到我的视图中。函数getTemp按预期工作,并且$scope.temperatures已正确更新(我可以在控制台中看到),但是新的数据值不会出现在视图中。我不确定什么东西没有正确绑定

我已经看过了其他相关的问题,但没有一个是完全相同的

视图:


问题是表单中有
ng controller=“tempCtrl”
。这将创建其自己的当前作用域的子作用域。因此,放入此范围的任何对象都不会影响当前范围。尝试删除它:

 <div ng-controller="tempCtrl" class="container">
     <form id="zipCodeForm" ng-submit="submit()"> //remove your redundant ng-controller
         <input id="zipCodeInput" ng-model="text" name="text" type="text"> </input>
         <input id="zipSubmit" type="submit" value="Submit" class="btn btn-large btn-primary"></input>                  
     </form>
     <div>
          <h4 ng-repeat='item in temperatures'>
              Zip code is {{item.zip}} and temperature is {{item.temp}}
          </h4>
     </div>
</div>

//卸下冗余的ng控制器
邮政编码为{item.Zip}},温度为{{item.temp}

问题是表单中有
ng controller=“tempCtrl”
。这将创建其自己的当前作用域的子作用域。因此,放入此范围的任何对象都不会影响当前范围。尝试删除它:

 <div ng-controller="tempCtrl" class="container">
     <form id="zipCodeForm" ng-submit="submit()"> //remove your redundant ng-controller
         <input id="zipCodeInput" ng-model="text" name="text" type="text"> </input>
         <input id="zipSubmit" type="submit" value="Submit" class="btn btn-large btn-primary"></input>                  
     </form>
     <div>
          <h4 ng-repeat='item in temperatures'>
              Zip code is {{item.zip}} and temperature is {{item.temp}}
          </h4>
     </div>
</div>

//卸下冗余的ng控制器
邮政编码为{item.Zip}},温度为{{item.temp}

为什么html中有两个ng controller=“tempCtrl”?因为我编程太晚了,犯了一个错误!这就是问题所在!为什么html中有两个ng controller=“tempCtrl”?因为我编程太晚了,犯了一个错误!这就是问题所在!
 <div ng-controller="tempCtrl" class="container">
     <form id="zipCodeForm" ng-submit="submit()"> //remove your redundant ng-controller
         <input id="zipCodeInput" ng-model="text" name="text" type="text"> </input>
         <input id="zipSubmit" type="submit" value="Submit" class="btn btn-large btn-primary"></input>                  
     </form>
     <div>
          <h4 ng-repeat='item in temperatures'>
              Zip code is {{item.zip}} and temperature is {{item.temp}}
          </h4>
     </div>
</div>