Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up an Angular app


This recipe is a preliminary step necessary for every other recipe in this chapter. It shows you how to make the Angular Dart functionality available to your app.

How to do it...

  1. There is no angular template yet in Dart Editor, so start your app from a web application (mobile friendly), and call it, for example, angular_setup. Clear the sample code from the html and dart files.

  2. Add angular to the dependencies in pubspec.yaml. Saving will start the pub get procedure.

  3. Also add js and shadow_dom to pubspec.yaml.

  4. Add the shadow DOM script to the html file:

     <script src="packages/shadow_dom/shadow_dom.min.js"></script>
  5. Also, include the Angular transformer:

    transformers:
    - angular
  6. Provide the ng-app attribute in the <html> element.

  7. Add the following statement to the top of your main Dart script:

    import 'package:angular/angular.dart';
    import 'package:angular/application_factory.dart';
    
  8. In main(), insert the code applicationFactory().run();.

  9. Provide the ng-cloak...