Monday, 24 October 2016

Building A Notepad with Dart Angular 2 : Part Six

Another step in my personal 'Learn Angular 2' project... Here's some details of what made it into v0.06. I'd recommend looking at the entire project alongside this post.

Let's quickly add another function to the Text processing service:

  String getRepeatedString(String textToRepeat, num count) {
    count ??= 1;
    return textToRepeat * count.toInt();
  }

We use a null aware operator to set count to a default value and then use the string multiplication operator to do the required repeating.

The generate dialog is pretty much the same as the About dialog. It would be useful to have a base dialog class - alas I have not got this to work yet but I hope to follow it up.

There some more event stuff going on with the toolbar which now has a drop down menu (toolbar_component.html):

div (mouseenter)="show()" (mouseleave)="hide()" class="toolbarButton" 
The menu contents are hidden and shown with ngStyle:
[ngStyle]="{'display':  display}

Again, not too different to Angular 1 - just different syntax.

That's it for this time. Check the app out np8080.win and the code is on GitHub.