JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myApp">
<div ng-controller="FirstCtrl">
{{Data.x}}
{{Data.y.prop1}}
</div>
<hr>
</div>
JavaScript
// declare the app with no dependencies
var myApp = angular.module('myApp', []);
myApp.factory('Data', function(){
var obj = {
x: undefined,
y: {
prop1:undefined
}
}
return {
Trade:obj,
LoadTrade: function() {
var a=5;
var b = obj.y;
b.prop1=6;
obj = {
x: a,
y: b
}
}
};
});
myApp.controller('FirstCtrl', function( $scope, Data ){
Data.LoadTrade();
$scope.Data = Data.Trade;
});