问题
I have a project that needs a good performance with a large number of records showed.
My data structure:
- SERVERS (+- 15 per page)
- WEBSITES (+- 20 per server)
- USERS logged in with your STATUS (+- 500 per website)
- WEBSITES (+- 20 per server)
What is the best approach for my Objects and Controllers?
One Controller with one neasted object.
ServerCtrl -> $scope.Server[0].Websites[0].Users
One Controller with three lists
ServerCtrl -> $scope.Servers; $scope.Websites; $scope.Users
Three Controllers with three separated lists
ServerCtrl -> $scope.Servers
WebsiteCtrl -> $scope.Websites
UserCtrl -> $scope.Users
Thanks!
回答1:
It all depends on how you are working with the data in the controller.
- If you need access to all data for a specific server. Then you need data to the data inside the data. But it is a lot of data so maybe just read one server at the time or page?
- I would instead only read one service at the time. But it all depends on what you want to do. Are the server, website and user not connected to each other then fine.
- This approach works. Inside the server view you can have a website view with a controller and inside the website view you can have a user controller. It is a good way organize data. But the amount of data means that you probably need some sort of paging.
回答2:
The performance depends on how you manipulate the data. So you can use AngularJS Batarang (Chrome Extension) and check the number os watcher in your page and apply some methods to reduce this number and give more performance for your application. Be careful with big lists and two way data binding, filters... They're villains of performance.
来源:https://stackoverflow.com/questions/16763463/angularjs-performance