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 'dart:async'; | |
| import 'package:angular2/core.dart'; | |
| import 'package:angular2/platform/browser.dart'; | |
| import 'package:angular2/router.dart'; | |
| @Injectable() | |
| class TitleSetService { | |
| Router _router; | |
| Title _title; |
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
| TitleSetService(this._router, this._title) { | |
| _router.subscribe(_setTitleFromRoute); | |
| } | |
| void _setTitleFromRoute(String url) async { | |
| //identify component instruction from routed url | |
| ComponentInstruction compInst = (await _router.recognize(url))?.component; | |
| if (compInst != null) { | |
| _title.setTitle(compInst.routeName); | |
| } |
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
| typedef String TitleNamingFunction(ComponentInstruction c); | |
| @Injectable() | |
| class TitleSetService { | |
| TitleNamingFunction nameStrategy; | |
| Router _router; | |
| Title _title; | |
| TitleSetService(this._router, this._title) { |
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
| AppComponent(TitleSetService _titleSet) { | |
| _titleSet.nameStrategy = _setTitle; | |
| } | |
| String _setTitle(ComponentInstruction c) { | |
| StringBuffer sb = new StringBuffer(); | |
| sb.write("Title Set Demo | "); | |
| if (c.routeData.data.containsKey('title')) { // if title is in data, use it |
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
| @RouteConfig(const [ | |
| const Route(path: '/players', name: 'Players', component: PlayersComponent, useAsDefault: true), | |
| const Route(path: '/teams', name: 'Teams', component: TeamsComponent), | |
| const Route(path: '/fields', name: 'Fields', component: FieldsComponent, | |
| data: const{'title': 'Ballparks'}), | |
| const Route(path: '/player/:id', name: 'PlayerDetail', component: PlayerDetailComponent, | |
| data: const{'title': 'Player'}), | |
| ]) |
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
| @Injectable() | |
| class SiteStructureService { | |
| static final List<ArticleSection> structure = <ArticleSection>[ | |
| new ArticleSection("About Kittens") | |
| ..articles.add(new Article("Fuzzy")) | |
| ..articles.add(new Article("Warm")) | |
| ..articles.add(new Article("Curious")), | |
| new ArticleSection("Anatomy") | |
| ..articles.add(new Article("Paws")) | |
| ..articles.add(new Article("Whiskers")) |
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
| List<RouteDefinition> _getRouteConfig(List<ArticleSection> pages) { | |
| final List<RouteDefinition> config = <RouteDefinition>[]; | |
| for (int i = 0; i < pages.length; i++) { | |
| config.add( | |
| new Route(path: "/" + pages[i].routeSlug, | |
| name: pages[i].routeName, | |
| component: pages[i].component, | |
| data: <String,dynamic>{'id': pages[i].name})); | |
| } | |
| return config; |
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 *ngFor="let article of articles" class="content-item"> | |
| <h2>{{article.name}}</h2> | |
| <div class="content-html"> | |
| <div>Article content goes here</div> | |
| </div> | |
| </div> |
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 'dart:async'; | |
| abstract class ContentService { | |
| Future<String> getContent(String id); | |
| } |
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 'dart:async'; | |
| import 'dart:math'; | |
| import 'package:lorem/lorem.dart'; | |
| import 'package:angular2/core.dart'; | |
| import 'package:angular2_dart_asset_service/src/asset/content/content_service.dart'; | |
| @Injectable() | |
| class PlaceholderContentService implements ContentService { | |
| static const int maxDelay = 1500; //max simulated delay in milliseconds | |
| final Random _rnd = new Random(); |