SORU
17 Mayıs 2015, Pazar


Ne'ın bir Yönlendirici ayarlamak için doğru yolu & Angular2 Dart RouterLink

SoruNe bir Yönlendirici set & Angular2 Dart RouterLink için en uygun yolu budur

İşte benim ana.dosya dart:

import 'package:angular2/angular2.dart';
import 'package:angular2/router.dart';

import 'package:angular2/src/reflection/reflection.dart' show reflector;
import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities;


@Component(
    selector: 'home'
)
@View(
    template: '<h1>I am Home</h1><a router-link="child">Go Child</a>',
    directives: const [RouterOutlet, RouterLink]
)
class Home {}

//
//
//

@Component(
  selector: 'child'
)
@View(
    template: '<h1>I am Child</h1><a router-link="home">Go Home</a>',
    directives: const [RouterOutlet, RouterLink]
)
class Child {}

//
//
//

@Component(
  selector: 'index'
)
@View(
  template: '''
  <router-outlet></router-outlet>
            ''',
  directives: const [RouterOutlet, RouterLink]
)
class Index {
  Router router;

  Index(Router this.router) {
    router.config({ 'path': '/child', 'component': Child, 'alias': 'child'});
    router.config({ 'path': '/', 'component': Home, 'alias': 'home'});
  }

}

main() {
  reflector.reflectionCapabilities = new ReflectionCapabilities();
  bootstrap(Index, routerInjectables);
}

İşte benim yaklaşım:

Router_link.dart ben geri boş olarak newHref geliyor bakın

onAllChangesDone() {
    if (isPresent(this._route) && isPresent(this._params)) {
      var newHref = this._router.generate(this._route, this._params);
      this._href = newHref;
      // Keeping the link on the element to support contextual menu `copy link`

      // and other in-browser affordances.
      print('newHref');
      print(newHref);
      DOM.setAttribute(this._domEl, "href", newHref);
    }

Bu bir hataya yol açar ve navigasyon isteğini öldürüyor.

    String expected
STACKTRACE:
#0      BlinkElement.setAttribute_Callback_2 (dart:_blink:7565)
#1      BlinkElement.setAttribute_Callback_2_ (dart:_blink:7566)
#2      Element.setAttribute (dart:html:13673)
#3      BrowserDomAdapter.setAttribute (package:angular2/src/dom/browser_adapter.dart:258:25)
#4      RouterLink.onAllChangesDone (package:angular2/src/router/router_link.dart:66:23)

CEVAP
19 AĞUSTOS 2015, ÇARŞAMBA


app/partials/phone-list.html:

<div class="container-fluid">
  <div class="row">
    <div class="col-md-2">
      <!--Sidebar content-->

      Search: <input ng-model="query">
      Sort by:
      <select ng-model="orderProp">
        <option value="name">Alphabetical</option>
        <option value="age">Newest</option>
      </select>

    </div>
    <div class="col-md-10">
      <!--Body content-->

      <ul class="phones">
        <li ng-repeat="phone in phones | filter:query | orderBy:orderProp" class="thumbnail">
          <a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}"></a>
         <a href="#/phones/{{phone.id}}">{{phone.name}}</a>
          <p>{{phone.snippet}}</p>
        </li>
      </ul>

    </div>
  </div>
</div>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Autocar

    Autocar

    11 Mart 2006
  • Damian Winter

    Damian Winte

    27 ŞUBAT 2007
  • dhcrr's channel

    dhcrr's chan

    2 Ocak 2007