0

我有一个带有 3 个选项卡的应用程序,每个选项卡都从外部文件加载自己的模板。来自第一个选项卡的 ng-model 问题不会发送到第三个选项卡。

第一个文件:

<div class="row">
  <div class="span2 text-right">*Reported By:</div>
  <div class="span2"><input type="text" ng-model="date" required></div>
  <div class="span2 text-right">*Well Number:</div>
  <div class="span2">
    <select ng-model="well" required ng-change="wellFunc(well)" required>
      <option ng-selected>Well-01</option>
      <option>Well-02</option>
      <option>Well-03</option>
    </select>
  </div>
</div>

第二:

<table class="table table-hover table-striped">
  <tr>
    <th><strong>General Information:</strong></th>
  </tr>
  <tr>
    <td  ng-model="date"></td>
  </tr>
</table>

我也使用ui-router,也许路由器有问题?

var myApp = angular.module('myApp', ["ui.router"])
myApp.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/re");
$stateProvider
.state('re', {
  url: "/re",
  templateUrl: "template/general.html"
})
.state('ro', {
  url: "/ro",
  templateUrl: "template/corrective.html"
})
.state('ri', {
  url: "/ri",
  templateUrl: "template/result.html"
})

});

4

1 回答 1

0

我需要看到你的控制器来确认,但你可能会破坏你的约会。在您的控制器中,我假设您有类似的东西

$scope.date = "03/11/2014";

相反,做这样的事情

$scope.foo = { "date":"03/11/2014"}

并将您的 html 更新为

<input type="text" ng-model="foo.date" required>

现在,当用户更新输入时,它不会破坏其他“日期”引用,而只是更新 foo 引用的日期属性。查看此快速视频以获取说明。 https://egghead.io/lessons/angularjs-the-dot

于 2014-03-12T02:43:21.993 回答