This file contains hidden or 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
import { Input, Component, ViewEncapsulation, EventEmitter, Output } from '@angular/core'; | |
@Component({ | |
selector: 'custom-button', | |
template: `<button (click)="handleClick()">{{label}}</button>`, | |
styles: [` | |
button { | |
border: solid 3px; | |
padding: 8px 10px; | |
background: #bada55; |
This file contains hidden or 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
import { Directive, Input, OnInit, TemplateRef, ViewContainerRef } from '@angular/core'; | |
import { UserService } from './user.service'; | |
import { UserRole } from '../shared/models/user-role'; | |
@Directive({ | |
selector: '[tsIfRole]' | |
}) | |
export class IfRoleDirective implements OnInit { | |
role: UserRole; |
This file contains hidden or 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 . \ | |
&& yarn start | |
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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> |