【问题标题】:Redirecting to Url with additional custom data in AngularDart使用 AngularDart 中的其他自定义数据重定向到 Url
【发布时间】:2017-08-31 08:23:10
【问题描述】:

一个名称列表被填充,当点击该名称时,它会重定向到谷歌搜索。我需要帮助通过 html 将自定义填充数据 name 添加到 url,这将使用 Google 搜索的自动搜索结果重定向访问者。

app_component.html

     <h1>{{title}}</h1>

    <h2>My favorite hero is: {{myHero.name}}</h2>

    <p>Heroes:</p>

    <ul>

       <li *ngFor="let hero of heroes">

             <a href="https://www.google.co.in/search?q=">{{ hero.name }}</a>

       </li>

    </ul>

app_component.dart

     import 'package:angular2/angular2.dart';
     import 'src/hero.dart';


   @Component(
      selector: 'my-app', 
      template: '''app_component.html''', 

      directives: const [CORE_DIRECTIVES], )

      class AppComponent {
            String title = 'Tour of Heroes';
            List<Hero> heroes = [
              new Hero(1, 'Windstorm'),
              new Hero(13, 'Bombasto'),
              new Hero(15, 'Magneta'),
              new Hero(20, 'Tornado')
      ];
      Hero get myHero => heroes.first;
     }

【问题讨论】:

    标签: dart url-redirection angular-dart dart-html


    【解决方案1】:

    与将数据绑定到 HTML 的方式相同,您可以将其绑定到 HTML 属性,例如。这应该工作。

    <a href="https://www.google.co.in/search?q={{ hero.name }}">{{ hero.name }}</a>
    

    顺便说一句,您应该考虑将target="_blank" 属性也添加到链接中,这样用户将在新标签页中打开搜索,您的应用程序仍将继续运行。

    【讨论】:

    • 你能帮我如何在材料按钮上实现它
    • 根据按钮的 API 文档 (material.angular.io/components/button/overview),它应该类似于 &lt;a md-button href="http://google.com"&gt;click me!&lt;/a&gt;
    • 谢谢,但很抱歉我想在 上实现它我使用 angular_components 时的我
    猜你喜欢
    • 2016-02-29
    • 1970-01-01
    • 2018-05-11
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    相关资源
    最近更新 更多