我想将链接 href 属性绑定到控制器中的变量,但我也希望将该 url 绑定到变量。我想使用内置绑定来完成此操作,而无需手动查看更改并重新加载 url。这可能吗?
// In the controller
$scope.section = 'section1';
$scope.page = 'page1';
$scope.url = 'http://myurl/{{section}}/{{page}}';
<!-- In the template -->
<a ng-href="{{url}}">Page Link</a>
这是我实际代码的简化。在模板中声明 url 模式会起作用,但我需要在传入的字符串中定义 url。