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
ngapp() { | |
ng new $1 --style=sass --skip-npm && cd $1 && yarn \ | |
&& open http://localhost:4200 \ | |
&& code . | |
} |
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
ngapp() { | |
ng new $1 --style=sass --skip-npm && cd $1 && yarn | |
} |
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
ng new my-fancy-app --skip-npm && yarn | |
# |
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.formUtils') | |
.directive('submitIfValid', function () { | |
return { | |
restrict: 'A', | |
require: '^form', | |
link: function (scope, element, attrs, form) { | |
element.on('click', handleClick); | |
function handleClick() { |
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
<form name="aForm" novalidate> | |
<label for="name">Your email</label> | |
<input type="email" id="name" ng-model="name" name="aField" required> | |
<ng-messages for="aForm.aField.$error" | |
ng-show="aForm.aField.$invalid && aForm.aField.$dirty"> | |
<ng-message when="required">This field is required</ng-message> | |
<ng-message when="email">Please enter a valid email address</ng-message> | |
</ng-messages> | |
<button ng-click="save()" ng-disabled="aForm.$invalid">Send</button> | |
</form> |
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
<div ng-app="app"> | |
<form name="aForm" novalidate> | |
<label for="name">Your email</label> | |
<input type="email" id="name" ng-model="name" name="aField" required> | |
<ng-messages for="aForm.aField.$error"> | |
<ng-message when="required">This field is required</ng-message> | |
<ng-message when="email">Please enter proper email address</ng-message> | |
</ng-messages> | |
<button ng-click="save()">Send</button> | |
</form> |
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
mixin field-text(label) | |
label(for=attributes.id || attributes.name)= label | |
input.form-control(id=attributes.id || attributes.name, type='text')&attributes(attributes) | |
mixin field-errors(field) | |
ng-messages(for=field + '.$error', ng-show=field + '.$dirty && ' + field + '.$invalid', role='alert') | |
block |
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
include /angular_jade_form_mixins.jade | |
form(name='registration') | |
.form-group | |
+field-text('Username')(name='username', ng-model='user.username', ng-minlength='3', required='') | |
+field-errors('registration.username') | |
ng-message(when='required') Username is required | |
ng-message(when='minlength') Username must be at least 3 characters long |
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
form(name='registration') | |
.form-group | |
label(for='username') Username | |
input#username.form-control(type='text', required='', ng-minlength='3', | |
name='username', ng-model='user.username') | |
ng-messages(for='registration.username.$error', | |
ng-show='registration.username.$dirty && registration.username.$invalid', role='alert') | |
ng-message(when='required') Username is required | |
ng-message(when='minlength') Username must be at least 3 characters long |
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
<form name="registration"> | |
<div class="form-group"> | |
<label for="username">Username</label> | |
<input type="text" class="form-control" required ng-minlength="3" | |
id="username" name="username" ng-model="user.username"/> | |
<ng-messages for="registration.username.$error" | |
ng-show="registration.username.$dirty && registration.username.$invalid" role="alert"> | |
<ng-message when="required">Username is required</ng-message> | |
<ng-message when="minlength">Username must be at least 3 characters long</ng-message> | |
</ng-messages> |