I want to use angular' mechanism for deep property nesting , something that ng-model directive is using. I mean we can create very "deep" object in a scope by writing : ng-model="data.obj1.prop2.attr3.value4.text" in a view , so i want to do it easily in a controller/service too. I don't want to reinvent a wheel (or use this or this). Is there something undocumented like angular.create(path_str) ? 
            Asked
            
        
        
            Active
            
        
            Viewed 511 times
        
    2
            
            
         
    
    
        Community
        
- 1
- 1
 
    
    
        Ivan Chernykh
        
- 41,617
- 13
- 134
- 146
1 Answers
4
            One way you can achieve is by using $parse service. It has getter and setter function that i think can handle what you want
    var getter = $parse('prop1.prop2.prop3.prop4');
    var setter = getter.assign;
    setter($scope,"value1111");
See this fiddle http://jsfiddle.net/cmyworld/m7gxn/
And i think this also works
$scope.$eval("prop2.prop2.prop3.prop4=55");
 
    
    
        Chandermani
        
- 42,589
- 12
- 85
- 88
- 
                    This is how `ngModel` does it too. – Andyrooger Oct 11 '13 at 12:44
- 
                    great, i'll test it in a minute – Ivan Chernykh Oct 11 '13 at 12:52