AngularJS: 如何使用带范围变量的 ng-click
AngularJS: How to use ng-click with scope variable
在控制器中我有类似的东西
$scope.changeView = function ( path )
{
$location.path( path );
};
在 html 页面上,我有类似
的内容
<div ng-click="changeView( '/post/{{ post.content_id }}' )">
现在,当我查看源代码时,它似乎正确呈现为
<div ng-click="changeView( '/post/4' )">
但是,当我从浏览器进行实际点击时,它会将路径加载为 http://foo/#/post/{{ post.content_id }}
,而不是 http://foo/#/post/4
。
这是怎么回事?
这样试试
<div ng-click="changeView( '/post/'+ post.content_id )">
在控制器中我有类似的东西
$scope.changeView = function ( path )
{
$location.path( path );
};
在 html 页面上,我有类似
的内容<div ng-click="changeView( '/post/{{ post.content_id }}' )">
现在,当我查看源代码时,它似乎正确呈现为
<div ng-click="changeView( '/post/4' )">
但是,当我从浏览器进行实际点击时,它会将路径加载为 http://foo/#/post/{{ post.content_id }}
,而不是 http://foo/#/post/4
。
这是怎么回事?
这样试试
<div ng-click="changeView( '/post/'+ post.content_id )">