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
@Injectable() | |
export class TodosService { | |
/* ... */ | |
// pass all neccessary data as funcion parameters | |
toggleTodo(name: string) { | |
// retrieve model internal state | |
const todos = this.model.get(); |
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
export class TodosComponent { | |
/* ... */ | |
onTodoToggleClick(todo: Todo) { | |
this.todosService.toggleTodo(todo.name); | |
} | |
} |
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
@Component({ | |
selector: 'todos', | |
template: ` | |
<!-- | |
accessing multiple properties, | |
we're better off subscribing only once in component's ngOnInit() | |
--> | |
Done todos: {{count.done}} | |
Remaining todos: {{count.remaining}} | |
All todos: {{count.all}} |
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
@import '~@angular/material/theming'; | |
@include mat-core(); | |
@import 'my-theme.scss'; | |
// import custom componenet themes | |
// unofficial naming convention to support nice ordering of files in IDE | |
// to see theme under the original style file of the componenent | |
@import 'app/shared/big-input/big-input.component.scss-theme'; |
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
@import '~@angular/material/theming'; | |
// mixin name will be used in main style.scss | |
@mixin big-input-component-theme($theme) { | |
// retrieve variables from theme | |
// (all possible variables, use only what you really need) | |
$primary: map-get($theme, primary); | |
$accent: map-get($theme, accent); | |
$warn: map-get($theme, accent); |
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
import { Injectable, Component, NgModule, defineInjectable } from '@angular/core'; | |
/** | |
* @fileoverview added by tsickle | |
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | |
*/ | |
var SomeLibService = /** @class */ (function () { | |
function SomeLibService() { | |
} | |
SomeLibService.decorators = [ |
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
function changeMac() { | |
local mac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') | |
sudo ifconfig en0 ether $mac | |
sudo ifconfig en0 down | |
sudo ifconfig en0 up | |
echo "Your new physical address is $mac" | |
} |
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
/* session and clients models in some component or service */ | |
const filteredClients$ = this.sessionService.session$ | |
.combineLatest(this.clientService.clients$) | |
.map(([session, clients]) => clients.filter(client => { | |
if (client.vip && session.accessVips) { | |
return true; | |
} else if (!client.vip) { | |
return true; | |
} |
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
/* route configuration */ | |
const routes: Routes = [ | |
{ | |
path: 'todos', | |
component: TodosComponent, | |
resolve: { | |
todosInitialized: TodosService | |
} | |
} | |
/* ... */ |
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
import { NgModule } from '@angular/core'; | |
import { MODEL_PROVIDER } from './model.service'; | |
@NgModule({ | |
/* ... */ | |
providers: [MODEL_PROVIDER] | |
}) | |
export class CoreModule { } |
OlderNewer