Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $scope更新未在Angularjs中显示_Javascript_Angularjs_Ui.bootstrap - Fatal编程技术网

Javascript $scope更新未在Angularjs中显示

Javascript $scope更新未在Angularjs中显示,javascript,angularjs,ui.bootstrap,Javascript,Angularjs,Ui.bootstrap,$scope似乎与Angularjs中的更新不同步 我使用ui.bootstrap.timepicker更新我的时间值(myst和myet),然后在显示userscheds[index]时使用alert(JSON.stringify($scope.userscheds[index]),仅显示原始值。我错过了什么 任何帮助都将不胜感激 请参阅下面的我的或代码 更新#1 在ng model=“this.myst”中,从@dgig删除此。的注释。更改为ng model=“myst” 但是更新完成后,我

$scope似乎与Angularjs中的更新不同步

我使用ui.bootstrap.timepicker更新我的时间值(myst和myet),然后在显示
userscheds[index]
时使用
alert(JSON.stringify($scope.userscheds[index]),仅显示原始值。我错过了什么

任何帮助都将不胜感激

请参阅下面的我的或代码

更新#1

ng model=“this.myst”
中,从@dgig删除
此。
的注释。更改为
ng model=“myst”

但是更新完成后,我的$scope仍然没有显示

html模态

<div class="container" ng-app="appUserSchedule">
<div ng-controller="CtrlUserSchedule" >

<div class="row">
      <ul>
        <li ng-repeat="x in userscheds">{{x.week_day}} {{x.time_start}}-{{x.time_end}}
            <span ng-click="ctrl.showModal($index)" style="cursor:pointer;">Edit</span>
            <span ng-click="ctrl.removeItem($index)" style="cursor:pointer;">Delete</span>
        </li>
      </ul>
</div>


<!-- Modal -->  
<script type="text/ng-template" id="modalContent.html">
<div class="modal-body">
<div class="row">
<div class="col-sm-6">
  <timepicker ng-model="myst" hour-step="1" minute-step="15" show-meridian="true"></timepicker>
</div>
<div class="col-sm-6">
  <timepicker ng-model="myet" hour-step="1" minute-step="15" show-meridian="true"></timepicker>
</div>
</div>
<div class="modal-footer">
  <button class="btn btn-primary" ng-click="$close()">OK</button>
  <button class="btn btn-primary" ng-click="saveUserScheduleEntry()">Save</button>
</div>
json


您的警报显示了什么?
{id:1,“周日”:“星期一”,“日期时间开始”:“2016-03-08T08:00:00-05:00”,“日期时间结束”:“2016-03-08T12:00:00-05:00”,“时间开始”:“08:00”,“时间结束”:“12:00”,“$$hashKey”:“对象:3”}
如果我编辑/保存数据中的第一个条目。那是在我更新数据并保存之后。所以它显示了原始数据。对不起,我真的不确定。你有很多事情要做-如果你看这里的模态示例(),它们有两个独立的控制器-你的Plunk中只有一个。我甚至不能让模态在你的车里出现。也许你的真实代码中有更多,我不确定。无论如何,祝你好运。谢谢@dgig。要弹出模式,请单击“编辑”,它应该可以工作
var app = angular.module("appUserSchedule", ['ui.bootstrap']); 
app.controller("CtrlUserSchedule", function($scope,$http,$location,$modal) {

$scope.ctrl = this;

$http.get('userschedule.json').success(function(data, status, headers, config) {

    $scope.userscheds = data.userschedules;

    //console.log(data);
}).error(function(data, status, headers, config) {
    console.log("No data found..");
});


  // Show modal 
  this.showModal = function (index) {

  var modalInstance;

  modalInstance = $modal.open({
    templateUrl: 'modalContent.html',
    controller: 'CtrlUserSchedule',
    scope: $scope 
  });

  objts   = new Date($scope.userscheds[index].datetime_start);           
  objte   = new Date($scope.userscheds[index].datetime_end);       

  $scope.myst = objts;
  $scope.myet = objte;


      // Save User Schedule Entry details after making a change, then close modal    
      $scope.saveUserScheduleEntry = function() { 

      // Displays original value, but where are my updated values?
       alert(JSON.stringify($scope.userscheds[index]));

         $http.put('userschedule.json',index).success(function(eventsuccess){
       }).error(function(err){
           /* do something with errors */
       });

       modalInstance.close();
     };   

}
{
"userschedules":[
  {
     "id":1,
     "week_day":"Monday",
     "datetime_start":"2016-03-08T08:00:00-05:00",
     "datetime_end":"2016-03-08T12:00:00-05:00",
     "time_start":"08:00",
     "time_end":"12:00"
  },
  {
     "id":21,
     "week_day":"Monday",
     "datetime_start":"2016-03-08T13:00:00-05:00",
     "datetime_end":"2016-03-08T17:00:00-05:00",
     "time_start":"13:00",
     "time_end":"17:00"
  }, ...