angular.js - AngularJS不同Ctrl动态获取文本框的值
伊谢尔伦
伊谢尔伦 2017-05-15 16:54:38
0
1
606

$scope.deliveryModel = {

            "id": "delivery",
            "value": $rootScope.configInfo.queue.DelaySeconds,
            "disable": false,
            "tooltip": "值必须在0-900秒之间",
            "updateStatus": function (floatingIp) {
                if (floatingIp !== "0") {
                    this.disable = true;
                    this.value = 1;
                } else {
                    this.disable = false;
                }
            },
            "validate": [{
                "validFn": "required"
            }]
        };
        // 保留周期
        $scope.periodModel = {
            "id": "periodModel",
            "value":  $rootScope.configInfo.queue.MessageRetentionPeriod,
            "disable": false,
            "tooltip": "值必须在0-1209600秒之间",
            "updateStatus": function (floatingIp) {
                if (floatingIp !== "0") {
                    this.disable = true;
                    this.value = 1;
                } else {
                    this.disable = false;
                }
            },
            "validate": [{
                "validFn": "required"
            }]
        };
        // 最小消息大小定义
        $scope.sizeModel = {
            "id": "sizeCount",
            "value":  $rootScope.configInfo.queue.MaximumMessageSize,
            "disable": false,
            "tooltip": "值必须在0-256KB之间",
            "updateStatus": function (floatingIp) {
                if (floatingIp !== "0") {
                    this.disable = true;
                    this.value = 1;
                } else {
                    this.disable = false;
                }
            },
            "validate": [{
                "validFn": "required"
            }]
        };
        // 等待时间
        $scope.waitModel = {
            "id": "waitModel",
            "value":  $rootScope.configInfo.queue.PollingWaitSeconds,
            "disable": false,
            "tooltip": "值必须在0-20秒之间",
            "updateStatus": function (floatingIp) {
                if (floatingIp !== "0") {
                    this.disable = true;
                    this.value = 1;
                } else {
                    this.disable = false;
                }
            },
            "validate": [{
                "validFn": "required"
            }]
        };

我想在另外一个Ctrl中,动态的获取这几个文本框里面的值(可能有被修改的,也可能没被修改);
然而我现在获取能获取到,但是不能获取到改变的值。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

Antworte allen(1)
黄舟

你贴的这段代码想表达什么,说的获取有是什么?
在另外一个ctrl获取值的话可以使用:
ctrl1

$rootScope.$broadcast('listenChange', data);//data是传入需要监听的值

ctrl2

$rootScope.$on('listenChange', function(data){
  console.log(data);//这就是你从另外一个ctrl获到的值
});
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage