angularjs - What is the minimum work to get Angular working in a ASP.NET MVC/WEB Api template -
i transitioning on using angular , web api together. mvc/web api templates in visual studio have root path point homecontroller.cs returns view..
how root path point angular html file? concept of server side routing need go away somehow ? confused , have not found info on how transition mvc/web api template using angular , do files template creates.. far understand is
- create web api template in vs
- create index.html page in root directory contains ng directive other angular html pages , serves sort of master page them
- then guess need rid of asp.net mvc routing works in old school webforms type of way of specifying file default file?
let me take stab @ using same stack of asp.net mvc, webapi , angularjs. assuming creating spa.
first , foremost, keep web api out of picture. it's applicability limited sending data in different formats, there no view concepts in it.
you can use both server side routing , angular routing serve views user. can in fact complement each other.
like master page, angular need have main page, has ng-app
declaration. mvc standpoint home\index.cshtml
can loaded initial view. server size view generated index
page can contain ng-app
directive , ng-view
directive.
ng-view
main area views swapped\loaded.you can can compare ng-view
equivalent @renderbody()
method on server side. remember remove . don't remove renderbody loads main page. instead index page should loaded div @renderbody()
call master page when using angularng-view
in it.
you create server side views each partial view loaded in ng-view
. example, there userlist.cshtml
view gets loaded when route on client changes #/users
on client. load these view server need provide templateurl
in $routeprovide
, template url resolved server routing ( /user/index
).
things keep in mind while creating these child views is
- they should not inherit master page.
- hence should send content needs injected
ng-view
section, no<html>, <body>
tags. - they can contain angular binding , other angular declarative stuff.
once initial template loaded angular, may make call server again load data template. web api comes picture. call /api/users
return json data user. data returned can used bind view + data together.
hope have made myself clear.
Comments
Post a Comment