Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
Technical Personnal Blog

Technical Personnal Blog

Technical Personnal Blog

Technical Personnal Blog

  • Tech
  • Blog
  • Open Source
  • VEGAS
  • CARD
  • Favorite Link
  • Shop
  • Cart
  • Checkout
  • My account
  • Tech
  • Blog
  • Open Source
  • VEGAS
  • CARD
  • Favorite Link
  • Shop
  • Cart
  • Checkout
  • My account
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
BlogOpen SourceTech

Developing AngularJs applicatioin as a Beginner

By techsupport
December 31, 2015 2 Min Read
Comments Off on Developing AngularJs applicatioin as a Beginner

원문보기

 
Introduction

There are many tutorials available online, but still its difficult to understand. Here, I’ve explain how to begin with AngularJs as beginner in very simple way.

Background

You need to have basics of JAVASCRIPT to understand working.

Using the code

I am going to create an AngularJs app within ASP.Net MVC web application. In order to create the said application follow the below steps:

1. Create a new mvc web application in Visual Studio.

2. Install angularJS using NuGet server. ( Tools > NuGet Package Manager > Package Manager Console)

Hide Copy Code
PM> Install-Package angularjs

3. Create a new folder name “App” in root of the project

4. You can add separate folders to this app folder for controller, model, route, directive, assembly etc.

5. Now add App.js file under App folder by right clicking on App folder and selecting add new items.

6. Do coding as follows:

Hide Copy Code
(function () {

var app = angular.module(“app”, [ ]);

app.controller(“myCtrl”, [‘$scope’, function ($scope) {
$scope.value = “hello first app”;
}]);

})();

In above code, we have created a function which defines our app.

i.e.

Hide Copy Code
var app = angular.module(“app”, [ ]);

after defining app, a controller is added.

Hide Copy Code
app.controller(“myCtrl”, [‘$scope’, function ($scope) {

$scope.value = “hello first app”;

}]);

if you haven’t define app like below code. you need to use angular.controller instead of app.controller.

Hide Copy Code
var app = angular.module(“app”, [ ]);

in controller we have defined $scope.value = “hello first app;”. Here, value is model which holds some values.

save the file.

Here, We are done with App.js! Now we are going to use this AngularJs app in ASP.NET MVC view.

Follow the following steps to use AngularJs app in MVC View.

1. Add a controller in ASP.NET MVC web application’s root.

2. Create a view and define ng-app, ng-controller and ng-model in hierarchy, like follows:

Hide Copy Code
<div ng-app=”app”>

<div ng-controller=”myCtrl”>

<input type=”text” ng-model=”value” />

<label>{{value}}</label>

</div>

</div>

3. Now, Before Running the App you need to include following js in head tag of cshtml page. After including required js, you need to include App.js which we created.

Hide Copy Code
<script src=”~/Scripts/angular.js”></script>

<script src=”~/Scripts/angular-route.js”></script>

<script src=”~/Scripts/angular-resource.js”></script>

/* Below this include your app.js which was created under App folder */

<script src=”~/App/Controller/app.js”></script>
•{{value}} – This denotes 2 way binding which means that when you change the value of the textbox, it will directly reflect to the place where you have used 2 way binding.
•{{::value}} – This denotes 1 way binding. Unlike two way binding you’ll only see the value which you have set in the app module.

Now, Run the project. We are done with AngularJs.
License

Author

techsupport

Follow Me
Other Articles
Previous

워드 프로세스 패스워드 재세팅하기

Next

How To Build Web-Site With AJAX (HTML+CSS+JS+PHP) . . . XHR & jQuery . . .For Beginners

Categories

  • Android
  • Blog
  • Favorite Link
  • linux
  • Open Source
  • opencart
  • social
  • Tech
  • Uncategorized

Archives

  • January 2025
  • March 2024
  • August 2023
  • March 2023
  • February 2023
  • November 2021
  • August 2021
  • April 2021
  • March 2021
  • December 2020
  • October 2020
  • September 2020
  • July 2020
  • June 2020
  • May 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • September 2019
  • August 2019
  • June 2019
  • October 2018
  • August 2018
  • May 2018
  • April 2018
  • March 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • June 2017
  • March 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • January 2016
  • December 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
Copyright 2026 — Technical Personnal Blog. All rights reserved. Blogsy WordPress Theme