我是AngularJs的新手。我在控制器内的scope变量中放了一个url值。该值应该在javascript函数内与控制器对应的部分文件中使用。我怎样才能在AngularJs中实现这一点。
下面给出了代码段以供参考: 配置代码:
myApp.config(function ($routeProvider){
$routeProvider.
when('/state-details/:id',
{
controller:'controllers.StateDetailsCtrl',
templateUrl:'/partials/state-details.html'
})
.... More routes defined below...
控制器内部:
controllers.StateDetailsCtrl= function($scope, $routeParams, $http){
$scope.testURL='http://www.google.com'
.... More values set in the scope..
在state-details
部分文件中:
<script>
// how to get the value of the testURL defined in the scope?
</script>
请告诉我如何使其正常工作?
答案 0 :(得分:0)
如果你需要在部分html文件中添加额外的javascript,那就像尖叫一样使用指令。
在那里,您可以继承整个ctrl范围或创建一个独立的范围。