3

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.

1
  • Your approach is okay. You get mvc routing auth and filters and angular maintainability. It transitions well to using Web api later if you want to. Commented Oct 15, 2015 at 10:57

1 Answer 1

1

Angular JS is complete client end framework solution with tempting and routing feature, so if you are going to use it with MVC and Razor Views then Angular JS will be useful only for VM binding. In my opinion if you are going to use MVC with Razor views then you should go with KnockoutJS, which is very fast and lightweight.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.