search

Home  >  Q&A  >  body text

angular.js - AngularJS different Ctrl to dynamically get the value of the text box

$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"
            }]
        };

I want to dynamically obtain the values ​​​​in these text boxes (which may or may not have been modified) in another Ctrl;
However, I can obtain it now, but cannot obtain it. to the changed value.

伊谢尔伦伊谢尔伦2873 days ago678

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-15 16:56:38

    What does the code you posted want to express? What is the acquisition you are talking about?
    If you want to get the value from another ctrl, you can use:
    ctrl1

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

    ctrl2

    $rootScope.$on('listenChange', function(data){
      console.log(data);//这就是你从另外一个ctrl获到的值
    });

    reply
    0
  • Cancelreply