【发布时间】:2015-12-18 10:27:02
【问题描述】:
我有一个使用 MVC 6 和 angularjs 的新 ASP.NET 5 项目。
我的网页数据绑定按预期工作,但是当我在项目中使用 MVC 6 Anchor TagHelper 时,数据绑定没有按预期工作。
<div class="browse-movie-wrap col-lg-2 col-md-2 col-sm-3 col-xs-6" ng-repeat="movie in movies | filter:{IsPublished:true}">
CSHTML:
{{ movie.Id }} @*is working*@
<a asp-controller="Movie" asp-action="MovieDetail" asp-route-movieId="{{ movie.Id }}" class="browse-movie-link">
@*this does not work*@
</div>
生成的 HTML:
<div class="browse-movie-wrap col-lg-2 col-md-2 col-sm-3 col-xs-6 ng-binding ng-scope" ng-repeat="movie in movies | filter:{IsPublished:true}">
228 //id is binded
<a class="browse-movie-link" href="/Movie/MovieDetail?movieId=%7B%7B%20movie.Id%20%7D%7D">
//but not binded anchor tag helper its remains movieID
注意:代码在同一页
我还在 MVC 存储库中打开了一个问题。你可以找到它here。
【问题讨论】:
-
你的 {{ 正在被 asp.最好完全在 angularJs 中生成这个 href。使用 ng-href。
-
@yeouuu ,是的,现在正在寻找 angular js.anyway 感谢您的建议
标签: angularjs angularjs asp.net-mvc-routing asp.net-core asp.net-core-mvc