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.
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 thehtml
anddart
files.Add
angular
to the dependencies inpubspec.yaml
. Saving will start thepub get
procedure.Also add
js
andshadow_dom
topubspec.yaml
.Add the shadow DOM script to the
html
file:<script src="packages/shadow_dom/shadow_dom.min.js"></script>
Also, include the Angular transformer:
transformers: - angular
Provide the
ng-app
attribute in the<html>
element.Add the following statement to the top of your main Dart script:
import 'package:angular/angular.dart'; import 'package:angular/application_factory.dart';
In
main()
, insert the codeapplicationFactory().run();
.Provide the
ng-cloak
...