After the new Spring Festival, share the first tutorial.
is to teach a new friend to learn the new AngularJs language using ASP.
One, create a new empty Web project. Use NuGet to download AngularJs and jquery.
Two, configure BundleConfig.cs:
Public classBundleconfig {//for more information on bundling, visithttp://go.microsoft.com/fwlink/?LinkId=301862 Public Static voidregisterbundles (bundlecollection bundles) {//bundles. ADD (New Stylebundle ("~/bundles/css"). Include (//"~/content/css/angularvalidate.css"// ));bundles. ADD (NewScriptbundle ("~/bundles/jquery"). Include ("~/scripts/jquery-3.1.1.js" )); Bundles. ADD (NewScriptbundle ("~/bundles/angular"). Include ("~/scripts/angular.js", "~/scripts/angular-route.js" )); } }
Source Code
Three, configure Global.asax. Write the Application_Start () method to enable the Angularjs and jquery references above bundles.
Public class MvcApplication:System.Web.HttpApplication { protectedvoid Application_Start () { Arearegistration.registerallareas ( ); Filterconfig.registerglobalfilters (globalfilters.filters); true ; Bundleconfig.registerbundles (bundletable.bundles); Routeconfig.registerroutes (routetable.routes); } }
Source Code
Four, the project uses the ASP. NET MVC Framework layout:
Five, create a controller for ASP. NET MVC:
Six, under the project, create a ANGULARJS directory that will be used to store ANGULARJS code documents, such as apps or controllers. Create a new app.js below
Seven, create a view for ASP. NET MVC:
The above HTML program, has used the Ng-app,ng-model and ng-bing and other instructions, the actual explanation, can be officially explained.
Here's a demonstration of the program running interaction:
Using the Angularjs language under ASP. (a): Hello your Name