繁体   English   中英

$ scope在AngularJS中未更改

[英]$scope isn't changed in AngularJS

我正在写一个调度服务,所以每周有很多时间。 当您每次单击它的Unix格式将发送给模态并且用户可以预订时,现在我想通过编写以下代码将Unix时间传递给ngDialog模块。

游戏内截图

订票服务 预订服务的看法

当您单击9:00按钮时,将打开modal(ngDialog) 当您单击9:00按钮时,将打开modal(ngDialog)

Unix时间 我想在上面的输入中输入Unix时间。

调节器

schedule.controller('schedule', ['$scope', '$http', 'ngDialog', function($scope, $http, ngDialog) {
$http.get('/zt-api/business/admin/' + window.location.pathname.split('/')[2]).success(function(data) {
        $scope.admin_times = data;
        $scope.duration = {
            startTime: "",
            endTime: ""
        };
        $scope.clickToOpen = function(start) {
            ngDialog.openConfirm({
                template: '/static/partials/staff_admin/ngdialog/admin_block_time.html',
                scope: $scope
            }).then(function(value) {
                console.log(value);
            }, function(reject) {
                console.log(reject);
            });
            $scope.duration.startTime = start;
            console.log($scope.duration)
        };
    }
});
});
}]);

HTML

<div class="morning"  ng-hide="hideMorning" ng-repeat="(key4, array4) in array3.times | filter: {'part': 'morning'}">
    <div class="daytime" ng-click="clickToOpen(array4.unix)" id="{[{ array4.unix }]}" ng-show="array4.part=='morning'">{[{ array4.timestamp.split(" ")[1].slice(0,5) }]}</div>
</div>

**array4.unix returns Unix time.**

我想在运行clickToOpen函数时能够将$scope.duration.startTime更改$scope.duration.startTime start ,但是更改时间不到一秒钟! 我该如何修改?

如果将控制器添加到ngDialog.openConfirm()并像这样记录$ scope。

ngDialog.openConfirm({
            template: 'templateId',
            controller: function($scope){
              console.log($scope);
            },
            scope: $scope
        }).then(function(value) {
            console.log(value);
        }, function(reject) {
            console.log(reject);
        });

}

您将注意到通过$ scopes。$ parent对象可访问父控制器的所有传入值,如下图所示。 这里是一个普拉克的作品传递$范围ngDialog和显示主控制器$ scope.dateTime里面ngDialog一个输入框

$ scopes父级

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM