-
-
Save devopsmariocom/8c47b64cc374b685ce1b64affa66c122 to your computer and use it in GitHub Desktop.
ngMetadata transclude=element terminal=true
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 { Component } from 'ng-metadata/core'; | |
import { BeerComponent } from './beer.component.ts'; | |
import { FoamDirective } from './foam.directive.ts'; | |
import { TasteDirective } from './taste.directive.ts'; | |
@Component({ | |
selector: 'my-app', | |
template: '<my-beer my-foam my-taste></my-beer>', | |
directives: [ BeerComponent, TasteDirective, FoamDirective ] | |
}) | |
export class AppComponent { } |
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 { Component } from 'ng-metadata/core'; | |
@Component({ | |
selector: 'my-beer', | |
template: '<h1>My First Angular 1 App <small>with ng-metadata!</small></h1>' | |
}) | |
export class BeerComponent implements OnInit { | |
ngOnInit() { | |
console.log( 'my-beer' ) | |
} | |
} |
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, Inject } from 'ng-metadata/core'; | |
@Directive( { | |
selector: '[my-foam]', | |
legacy: { | |
priority: 599, // Run right after ngIf | |
// to allow use ngIf on decorated components | |
// but prevent other directives to be linked | |
transclude: 'element', | |
terminal: true // TODO: Doesn't seems to be necessary | |
// as rest of directives are executed either way on $transclude call | |
} | |
}) | |
export class FoamDirective implements OnInit { | |
constructor( | |
@Inject( '$transclude' ) private $transclude: ng.ITranscludeFunction, | |
@Inject( '$element' ) private $element: ng.IAugmentedJQuery | |
) {} | |
ngOnInit() { | |
console.log('my-foam'); | |
this.$element.after( this.$transclude() ); | |
} | |
} |
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
export { AppComponent } from './app.component'; |
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 { bootstrap } from 'ng-metadata/platform-browser-dynamic'; | |
import { AppComponent } from './index'; | |
bootstrap( AppComponent ); |
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 } from 'ng-metadata/core'; | |
@Directive( { | |
selector: '[my-taste]' | |
}) | |
export class TasteDirective implements OnInit { | |
ngOnInit() { | |
console.log('my-taste'); | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- 1. Load libraries --> | |
<!-- Polyfill(s) for older browsers --> | |
<script src="https://npmcdn.com/core-js/client/shim.min.js"></script> | |
<script src="https://npmcdn.com/[email protected]"></script> | |
<script src="https://npmcdn.com/[email protected]/dist/system.src.js"></script> | |
<script src="https://code.angularjs.org/1.5.7/angular.js"></script> | |
<!-- 2. Configure SystemJS --> | |
<script src="systemjs.config.js"></script> | |
<script> | |
System.import('app').catch(function(err){ console.error(err); }); | |
</script> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<!-- 3. Display the application --> | |
<body> | |
<my-app>Loading...</my-app> | |
</body> | |
</html> |
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
console.log('Hello World!'); |
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
/* todo: add styles */ |
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
System.config({ | |
//use typescript for compilation | |
transpiler: 'ts', | |
typescriptOptions: { | |
tsconfig: true | |
}, | |
meta: { | |
'typescript': { | |
"exports": "ts" | |
} | |
}, | |
//map tells the System loader where to look for things | |
map: { | |
'app': './app', | |
'ng-metadata': 'https://npmcdn.com/ng-metadata', | |
'rxjs': 'https://npmcdn.com/[email protected]', | |
'ts': 'https://npmcdn.com/[email protected]/lib/plugin.js', | |
'typescript': 'https://npmcdn.com/[email protected]/lib/typescript.js', | |
}, | |
//packages defines our app package | |
packages: { | |
app: { | |
main: './main.ts', | |
defaultExtension: 'ts' | |
}, | |
'ng-metadata': { | |
defaultExtension: 'js' | |
}, | |
'rxjs': { | |
main: 'index.js', | |
defaultExtension: 'js' | |
} | |
} | |
}); |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"removeComments": false, | |
"noImplicitAny": true, | |
"suppressImplicitAnyIndexErrors": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment