简体   繁体   中英

How to change popup title scope variable dynamically when button click in AngularJS

I have two popup's having in a single html page, i need to change the popup title based on popup click. I'm using title for $scope variable. I tried the below code but it is not changing the title, please help me on this.

Html:

<div id="Popup" title="{{title}}">
  <div data-ng-include src="'Partials/Popup.html'" data-ng-show="newPopup"></div>
</div>

JS:

$scope.PopupOne = function() {
  $scope.title = 'Popup One'; // I tried this
  $scope.ShowPopup('Popup');
  Factory.HttpRequest('ABC1.ashx', dataJson)
    .success(function(dt) {
        //parameters
      }
    };
}

$scope.PopupTwo = function() {
  $scope.title = 'Popup Two'; //I tried
  $scope.ShowPopup('Popup');
  Factory.HttpRequest('ABC2.ashx', dataJson)
    .success(function(dt) {
        //parameters
      }
    };
}

When i click popup button on the popup title is not showing but i can able to see at inspect elements Please see the image

var myDynamicValue = $scope[title];
$scope.PopupTwo = function () {
    $scope.title = myDynamicValue; //I tried
    $scope.ShowPopup('Popup'); 
    Factory.HttpRequest('ABC2.ashx', dataJson)
        .success(function (dt) {
         //parameters
       } 
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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