Created
May 14, 2014 11:18
-
-
Save mono0926/2e8b58d3003f1fcbfa1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../../typings/tsd.d.ts" /> | |
function HelloWorldController($scope) { | |
$scope.message = 'Hello World!!'; | |
} | |
function SampleController($scope) { | |
$scope.simple = '簡易記法を使った方法'; | |
$scope.directive = 'ディレクティブを使った方法'; | |
} | |
function SampleController2($scope) { | |
$scope.text = 'TextBox'; | |
$scope.checkbox = true; | |
$scope.radio = 'FUGA'; | |
$scope.select = 'foo'; | |
} | |
function SampleController3($scope) { | |
$scope.click = () => { | |
$scope.message = 'click button!'; | |
}; | |
} | |
function SampleController4($scope) { | |
$scope.items = [ | |
{key: 'hoge', value: 'HOGE'}, | |
{key: 'fuga', value: 'FUGA'}, | |
{key: 'piyo', value: 'PIYO'} | |
] | |
} | |
function SampleController5($scope) { | |
$scope.hidden = true; | |
$scope.click = () => { | |
$scope.hidden = !$scope.hidden; | |
}; | |
} | |
function SampleController6($scope) { | |
$scope.hoge = 'red solid-border'; | |
$scope.isRed = true; | |
$scope.isDotted = true; | |
} | |
function SampleController7($scope) { | |
$scope.url = 'http://mono0926.com/'; | |
$scope.imageFileName = 'mate.png'; | |
} | |
function SampleController8($scope) { | |
$scope.message = 'hoge' | |
$scope.change = () => { | |
$scope.message = 'change!!' | |
} | |
} | |
function SampleController9($scope) { | |
$scope.hoge = 0; | |
$scope.fuga = 0; | |
$scope.sum = 0; | |
// Angular式 | |
// $scope.$watch('hoge + fuga', 'sum = hoge + fuga'); | |
// 関数式 | |
$scope.$watch(() => $scope.hoge + $scope.fuga, | |
() => { | |
$scope.sum = $scope.hoge + $scope.fuga; | |
}); | |
} | |
(function() { | |
var myModule = angular.module('myModule', ['ngRoute']); | |
// モジュールを定義する | |
myModule.controller('SampleController10', $scope => { | |
$scope.message = 'module'; | |
}); | |
// 依存するインスタンス(サービス)をインジェクションする | |
myModule.service('sampleService', SampleService); | |
myModule.controller('SampleController11', ($scope, sampleService) => { | |
$scope.message = sampleService.method(); | |
}); | |
function SampleService() { | |
this.method = () => { | |
return 'sample service'; | |
}; | |
} | |
// フィルターを自作する | |
myModule.filter('myFilter', function() { | |
return function(value, param1, param2) { | |
return param1 + value + param2; | |
}; | |
}); | |
// ngRouteモジュールを追加する | |
myModule.config($routeProvider => { | |
$routeProvider | |
.when('/', { | |
controller: 'RootController', | |
templateUrl: 'users' | |
}); | |
}); | |
myModule.controller('RootController', function($scope) { | |
$scope.message = 'message by RootController.'; | |
}); | |
})(); | |
function SampleController12($scope) { | |
$scope.money = 1000; | |
} | |
function SampleController13($scope) { | |
$scope.array1 = ["hoge", "fuga", "piyo"]; | |
$scope.array2 = [ | |
"hoge", | |
"fuga", | |
{a: "hoge"}, | |
{a: "fuga"}, | |
{b: {c: "hoge"}}, | |
{b: {c: "fuga"}}, | |
]; | |
} | |
function SampleController14($scope) { | |
$scope.physicists = [ | |
{firstName: 'Johannes', lastName: 'Kepler'}, | |
{firstName: 'Galileo', lastName: 'Galilei'}, | |
{firstName: 'Thomas', lastName: 'Young'}, | |
{firstName: 'Michael', lastName: 'Faraday'}, | |
{firstName: 'Edward', lastName: 'Morley'}, | |
{firstName: 'Niels', lastName: 'Bohr'} | |
]; | |
} | |
function SampleController15($scope) { | |
$scope.isEvenNumber = number => number % 2 == 0; | |
} | |
function SampleController16($scope) { | |
$scope.contains = (actual, expected) => | |
actual.indexOf(expected) != -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment