Created
October 23, 2017 12:56
-
-
Save gmittica/06f2b57231d2a90bcc730c55aeb98b09 to your computer and use it in GitHub Desktop.
Lesson // source http://jsbin.com/tebozuh
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> | |
<head> | |
<script src="https://code.jquery.com/jquery.min.js"></script> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Lesson</title> | |
<style id="jsbin-css"> | |
.container { | |
margin-top:45px; | |
} | |
</style> | |
</head> | |
<body ng-app="myApp"> | |
<div class="container" ng-controller="myCtrl"> | |
<form class="form" ng-submit="sendForm()" novalidate> | |
<div class="form-group"> | |
<input type="text" ng-model="form.title" class="form-control" placeholder="Write here" required="required"> | |
</div> | |
<div class="form-group"> | |
<select | |
ng-model="form.tag" | |
ng-options="key as tag.name disable when (tag.category == 'lifestyle') for (key, tag) in tags" | |
class="form-control" required="required"></select> | |
</div> | |
<div class="form-group"> | |
<button type="submit" class="btn btn-info" >Save</button> | |
</div> | |
</form> | |
<div class="well"> | |
{{ tags | json }} | |
</div> | |
<div class="well"> | |
{{ form | json }} | |
</div> | |
</div> | |
<script id="jsbin-javascript"> | |
angular.module("myApp", []) | |
.controller("myCtrl", ['$scope', function($scope) { | |
$scope.form = { | |
title: 'default title', | |
tag: 'cl' | |
} | |
/*$scope.tags= [ | |
"PC", "Sport", "Cloud" | |
]; | |
// tag for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{name: "PC"}, | |
{name: "Sport"}, | |
{name: "Cloud"} | |
]; | |
// tag.name for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{name: "PC" , category: "tech"}, | |
{name: "Sport", category: "lifestyle"}, | |
{name: "Cloud", category: "tech"} | |
]; | |
tag.name group by tag.category for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{id:1, name: "PC" , category: "tech"}, | |
{id:2, name: "Sport", category: "lifestyle"}, | |
{id:3, name: "Cloud", category: "tech"} | |
]; | |
tag.id as tag.name for tag in tags | |
*/ | |
$scope.tags= { | |
"pc": { name: 'PC', category: "tech"}, | |
"sp": { name: 'Sport', category: "lifestyle"}, | |
"cl": { name: 'Cloud', category: "tech"}, | |
}; | |
$scope.sendForm = function() { | |
// do something with $scope.form | |
} | |
}]); | |
</script> | |
<script id="jsbin-source-css" type="text/css">.container { | |
margin-top:45px; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular.module("myApp", []) | |
.controller("myCtrl", ['$scope', function($scope) { | |
$scope.form = { | |
title: 'default title', | |
tag: 'cl' | |
} | |
/*$scope.tags= [ | |
"PC", "Sport", "Cloud" | |
]; | |
// tag for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{name: "PC"}, | |
{name: "Sport"}, | |
{name: "Cloud"} | |
]; | |
// tag.name for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{name: "PC" , category: "tech"}, | |
{name: "Sport", category: "lifestyle"}, | |
{name: "Cloud", category: "tech"} | |
]; | |
tag.name group by tag.category for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{id:1, name: "PC" , category: "tech"}, | |
{id:2, name: "Sport", category: "lifestyle"}, | |
{id:3, name: "Cloud", category: "tech"} | |
]; | |
tag.id as tag.name for tag in tags | |
*/ | |
$scope.tags= { | |
"pc": { name: 'PC', category: "tech"}, | |
"sp": { name: 'Sport', category: "lifestyle"}, | |
"cl": { name: 'Cloud', category: "tech"}, | |
}; | |
$scope.sendForm = function() { | |
// do something with $scope.form | |
} | |
}]);</script></body> | |
</html> |
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
.container { | |
margin-top:45px; | |
} |
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
angular.module("myApp", []) | |
.controller("myCtrl", ['$scope', function($scope) { | |
$scope.form = { | |
title: 'default title', | |
tag: 'cl' | |
} | |
/*$scope.tags= [ | |
"PC", "Sport", "Cloud" | |
]; | |
// tag for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{name: "PC"}, | |
{name: "Sport"}, | |
{name: "Cloud"} | |
]; | |
// tag.name for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{name: "PC" , category: "tech"}, | |
{name: "Sport", category: "lifestyle"}, | |
{name: "Cloud", category: "tech"} | |
]; | |
tag.name group by tag.category for tag in tags | |
*/ | |
/* | |
$scope.tags= [ | |
{id:1, name: "PC" , category: "tech"}, | |
{id:2, name: "Sport", category: "lifestyle"}, | |
{id:3, name: "Cloud", category: "tech"} | |
]; | |
tag.id as tag.name for tag in tags | |
*/ | |
$scope.tags= { | |
"pc": { name: 'PC', category: "tech"}, | |
"sp": { name: 'Sport', category: "lifestyle"}, | |
"cl": { name: 'Cloud', category: "tech"}, | |
}; | |
$scope.sendForm = function() { | |
// do something with $scope.form | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment