Using Object.create Method in An Array Within An Object Is Not Binding to ng-model

时间:2018-07-24 10:10:12

标签: angularjs typescript

I have an object that contains a few properties and an array.

this._scope.SampleObject = {
    "Name": "Sample",
    "List": 
    [
        { 
            "Title": "Sample Title1",
            "HasValue": false 
        },
        { 
            "Title": "Sample Title2",
            "HasValue": false 
        }
    ]
}

Now once I pass this object in an ng-click directive, I use Object.create to create a separate instance of it.

//View
<button ng-click="Method(SampleObject)">Click</button>

// After the button above is clicked, a modal displays showing this HTML.
<div ng-repeat="item in Object2.List">
    <input type="checkbox" ng-model="item.HasValue" />
</div>

//Controller
$scope.Method = (SampleObject: any) => {
    this._scope.Object2 = Object.create(SampleObject);
}

My problem is that whenever I try to toggle the checkbox, the SampleObject is still the one being updated. Is there anything wrong with my code?

Thanks in advance for the help!

0 个答案:

没有答案
相关问题