Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can AngularDart route directly to a component?

I'm using AngularDart and routing. My views are one-liners that contain a single component. I feel the views are not carrying their weight. Can I route directly to a component?


Example:

router.root
  ..addRoute(
      name: 'welcome',
      path: '/welcome',
      defaultRoute: true,
      enter: view('views/welcome.html'))
  ..addRoute(
      name: 'camera',
      path: '/camera',
      enter: view('views/camera.html'));

And here's views/welcome.html

<welcome></welcome>

And here's views/camera.html

<camera></camera>

As you can see, those views are pretty weak. I'm much rather say: "when you enter a view, insert this component"

Is that possible?

like image 688
Seth Ladd Avatar asked Jan 10 '14 23:01

Seth Ladd


People also ask

How do angular routes work?

Angular Routinglink As users perform application tasks, they need to move between the different views that you have defined. To handle the navigation from one view to the next, you use the Angular Router . The Router enables navigation by interpreting a browser URL as an instruction to change the view.


1 Answers

This seems to be directly supported now

see https://github.com/angular/angular.dart/issues/425

You can route to an inline template (viewHtml):

views.configure({
  'foo': ngRoute(
      path: '/foo',
      viewHtml: '<foo-component></foo-component>')
});
like image 144
Günter Zöchbauer Avatar answered Sep 22 '22 01:09

Günter Zöchbauer