LoginSignup
8
10

More than 5 years have passed since last update.

VisualStudioでAngularJSとASP.NETを使ってHelloWorld

Last updated at Posted at 2016-03-20

目的:できるだけシンプルにVisualStudioでAngularJSを実行する。
理由:VisualStudioでWebSiteを構築しようとすると、情報が多く複雑すぎるため初心者には難しい。
初心者が理解しやすいように必要最低限な情報で構成した。
実行方法:
1.https://github.com/redpeaks33/AngularJS_HelloWorld_VisualStudio.git
ダウンロード して解凍
2.ソリューション(.slnファイル)をクリック して VisualStudio起動
3.実行(Ctrl + F5)

フォルダ構成
Folders.png

自作Controller

controller.js
var main = angular.module("app",[]);
main.controller('MyController', ['$scope', function ($scope) {
    $scope.message = 'Hello World!!';
}]);

Htmlファイル

index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="app">

<head>
    <title></title>
    <script src="/AngularJS/angular.min.js"></script>
    <script src="/js/controller.js"></script>
</head>
<body>
    <h1 ng-controller="MyController">{{message}}</h1>
</body>
</html>

ポイント
1.AngularJS本体と自作Controllerを<script>で設定
2.ng-appとng-controllerを設定する
3.ルート直下にindex.htmlを置く

おしまい

8
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10