I have a knockoutjs+requirejs background.
I switch to angularjs.
I do not like that in angularjs every bound propert is just attached to the $scope inside the controller.
From a knockoutjs perspective using angularjs now I just would do this:
create a customerviewmodel.js file.
Inside I create a constructor like:
function CustomerViewModel(dataFromServer)
{
this.data = dataFromServer;
// and many more properties
}
In my controller.js I would then just do:
var dataFromServer = service.GetData();
$scope = new CustomerViewModel(dataFromServer);
What I prefer about this approach that I have encapsulated my UI-Logic in separate object which I can easily unit test and I do not have to create a controller to unit test UI-Logic which seems very hard because I have to mock out the service call going to the webserver... Also I can reuse my customerviewmodel.js file at multiple places how is this possible when every property is stitched to a controllers $scope?
Does my approach implies unneeded steps or problems I can not think of now due to my zero experience with angularjs?
Is my approach worse concerning testability/extendability/maintainability vs the common approach people do using angularjs a long time?