【问题标题】:Navigate to a html from button tag从按钮标签导航到 html
【发布时间】:2016-08-31 22:10:34
【问题描述】:

i 有一些表格的 ng-repeat。每个表单都有一个按钮 - 编辑配置文件,它需要使用 $stateParam(userId) 将用户重定向到 /userProfile。

这是我的代码:

    <button type="button"  class="btn btn-grey btn-ripple">Edit profile</button>

我尝试了以下操作,没有成功:

 <a href="/userProfile?userId={{staff.UserId}}"  class="btn btn-grey btn-ripple">Edit profile</a>                 

- 工作正常,但 css 在&lt;a&gt; 标签上不能正常工作

我试图将&lt;button&gt; 标签包含到&lt;a&gt; 之一中,不起作用。

我想用 HTML 制作,没有 javascript 。我尝试使用form 标签和action=url,不起作用,他尝试访问"http:\\"url。

有什么建议吗?

谢谢

【问题讨论】:

  • 你在使用 Angular JS 吗?
  • 是的,我尝试使用 location.path(url) 但字符“?”进入编码后,网址不再起作用
  • 你能给我们看看 CSS 吗?
  • Works fine but the css doesn't work perfectly on &lt;a&gt; tag 那么你必须让它完美..我认为它只是一些应用一些规则的引导 css..你所要做的就是用你的自定义 css 覆盖引导 css..
  • 另外,使用 ng-href 而不是普通的 href。

标签: html css angularjs


【解决方案1】:

假设你使用的是 AngularJS,你可以这样做:

<button type="button" ng-click="location.assign('/userProfile?userId=' + staff.UserId)" class="btn btn-grey btn-ripple">Edit profile</button>

【讨论】:

    【解决方案2】:

    所以我尝试了这个:

       <a  href="/userProfile?userId={{staff.UserId}}">                                      
       <button type="button" class="btn btn-grey btn-ripple" >Edit profile</button>
       </a>             
    

    完美运行:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-09
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多