Angularjs: problem with array assignment

im facing an odd problem, I defined an object (globally for the application) that contains an array the object looks like

var _global = {
        document: {}, // represent selected item
    };

and in my service I have something like this

_global.document.signers =[{name:'test',email:'test@test.com'}];

works fine. now if i click an element like

_global.document.signers.push({name:'test',email:'test@test.com'});

and in the controller I use

var signers = _global.document.signers;

It works great. the view is updated with new values

but if I do something

_global.document.signers = [{name:'newTest',email:'newtest@test.com'}];

the global object is updated, but the view does not display new values, and if I change it to a push view, it starts rendering new values

Can someone tell me what I'm doing wrong. any help would be appreciated

Update

Thanks @shani for the help, I decided to use it

var draft = globalService.getGlobal(); //global service for maintaining global objects
$scope.draft = draft;

and in sight

 <ul class="list-unstyled font-11px" >
       <li ng-repeat="(signerIndex, signer) in draft.document.signers">
    </li></ul>
+3
source share
1 answer

, , , .

+2

All Articles