Created
May 20, 2016 00:22
-
-
Save soy-curd/9190c930fd07c744fbd0f224565c97f1 to your computer and use it in GitHub Desktop.
angular1x_typescript_snipet
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
var MyService = function (a, b) { | |
console.log(a); | |
return a + b; | |
}; | |
var MyController = function ($scope, addService) { // 自動で名前解決する | |
$scope.message = "Hello world"; | |
$scope.action = function ($event) { | |
if ($scope.message.indexOf("o") > 0) { | |
$scope.message = $scope.message.slice(0, -1); | |
} else { | |
$scope.message = "GooooooooodBye!"; | |
} | |
$scope.hoge = addService(10, 20); | |
$event.stopPropagation(); | |
console.log($event); | |
}; | |
}; | |
var appModule = angular.module("app", []); | |
appModule.value("addService", MyService) | |
appModule.controller("MyController", MyController); |
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
<!doctype html> | |
<html ng-app="app"> | |
<head> | |
<script src="angular.min.js"></script> | |
<script src="app.js"></script> | |
</head> | |
<body> | |
<div> | |
<label>Name:</label> | |
<input type="text" ng-model="yourName" placeholder="Enter a name here"> | |
<hr> | |
<h1>Hello {{yourName}}!</h1> | |
<p>{{1 + 1}}</p> | |
<div ng-init="variables=[1, 2, 3]" ng-if="yourName"> | |
<li ng-repeat="variable in variables"> | |
<p>{{variable}}</p> | |
</li> | |
</div> | |
<input type="text" ng-model="hoge" placeholder="Enter a name here"> | |
<hr> | |
<h1>Hello {{hoge}}!</h1> | |
</div> | |
<div ng-controller="MyController"> | |
<div ng-cloak> | |
{{message}} | |
{{hoge}} | |
<p ng-bind="hoge"></p> | |
</div> | |
<button ng-click="action($event)">push</button> | |
</div> | |
<input type="checkbox" ng-model="check"> | |
<div ng-if="check"> | |
ふが | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment