0

I'm using ng-include for recursion. it's loading correct at first time but when I change anything in the object at run time, it doesn't reflect the changes on html. ng-include will create a child scope for that, so its not getting changes from parent scope. How can I bind the scope or reflect the changes in the html? Below is the code snippet for main.html

<div ng-switch on="value.length>0">
   <div ng-switch-when="true">
    <div ng-init="item = value[0];" ng-include="'test/views/partialTemp.html'">

      </div>
     </div>
    </div>

In Partial Template

<div class="row"  ng-repeat="(key, result) in item" ng-if="item ">
    .......
<div ng-switch on="result.length > 0 ">
            <div ng-repeat="tempValue in result">
                <div ng-switch-when="true">
                    <div ng-init="item = tempValue;" ng-include="'test/views/partialTemp.html'"></div>
                </div>
            </div>
        </div>

....
</div>

In JS File

 onRadioButtonChange = function(key, value, item) {
    var self = this;

    self.serviceObj.Response.values = self.updateServiceObject(self.serviceObj.Response.values, key, value, false); // Updating the actual object which came from service
    self.objectToShow = JSON.parse(JSON.stringify(self.serviceObj));                // Taking the actual object which will show in the HTML
    self.objectToShow.Response.values = self.filterObjectToShow(self.objectToShow.Response.values); // it'll add/remove the child radio button

} 

objectToShow is the object which I'm using to render the html

  • `but when I change anything in the object at run time, it doesn't reflect the changes on html.` how do you change it? please show an example – Maxim Shoustin May 27 '20 at 06:21
  • @MaximShoustin Actually I'm creating Hierarchical radio buttons. If Parent radio button is selected then I'm showing the child radio button. So, on every radio button change I'm adding and removing the child radio buttons. So it's kind of tree of some records which are dependent on the selection of parent. example has been updated in the post – Ahamed Al Zubair Niloy May 28 '20 at 03:24
  • 7 years ago I wrote some demo that can be helpful: https://stackoverflow.com/a/19692791/1631379 – Maxim Shoustin May 28 '20 at 06:52

0 Answers0