I have started with asp mvc and angularjs, trying to create model-view-view-model structure for a new app i'm creating, the app will have crud operation on almost every page. Here is my experiment code.
Controller:
public ActionResult Index()
{
Database db = new Database();
ViewBag.data = db.getData();
return View();
}
View:
<ul class="Results" ng-init="dataLoad(@Json.Encode(ViewBag.data))">
<li data-ng-repeat="dat in dataToShow">
{{dat}}
</li>
</ul>
JavaScript Controller:
$scope.dataLoad = function (data) {
$scope.dataToShow = data;
}
I'm trying to get as much power from both technologies. In some places ill use razor(forms) in other angularjs depending on the need.
I don't have enough experience to know if this is a really bad idea e.g
- Maintainability
- What routing to use (asp mvc/ angularjs)
- How to handle crud operation (Api/ Post to Controller)
- Performance(big data may have impact on angularjs speed but still needs api calls for user convenience, why razor is ineffective)
Please any advise would help.