I am new to AngularJs. I have put a url value in the scope variable inside a controller. This value should be used in the partial file corresponding to the controller inside a javascript function. How can I achieve this in AngularJs.
Code snippet is given below for reference: Config code:
myApp.config(function ($routeProvider){
$routeProvider.
when('/state-details/:id',
{
controller:'controllers.StateDetailsCtrl',
templateUrl:'/partials/state-details.html'
})
.... More routes defined below...
Inside the controller:
controllers.StateDetailsCtrl= function($scope, $routeParams, $http){
$scope.testURL='http://www.google.com'
.... More values set in the scope..
Inside the state-details
partial file:
<script>
// how to get the value of the testURL defined in the scope?
</script>
Please let me know how to get this working?
ng-controller='StateDetailsCtrl'
on your html block and then you can call your scope variable with just{{testURL}}
– Tim Castelijns May 9 at 6:19<script>
tags? – Marc Kline May 9 at 6:21ng-controller='StateDetailsCtrl'
inside the html block and try to access thetestURL
inside the script tag I am getting an error. – Pradeep May 9 at 6:32