Hi,
Hi,

You can create a custom directive which acts an attribute to 
div#timeline-embed. Directive will be in the scope of controller and you 
can pass the timeline data to the directive to make it loosely coupled. 
Please refer to the following plunk:

http://plnkr.co/edit/BsvtEQImgtlUionti0E0

It is a very rudimentary implementation of your use case.

Thanks,

Vaibhav Gupta

On Wednesday, 28 October 2015 17:40:53 UTC+5:30, [email protected] wrote:
>
> I'm trying to create a simple application using AngularJS and TimelineJS3 
> but I'm having a problem with it.
>
> I have a state (*timeline*) which contains a partial view (timeline.html) 
> associated with a controller. This state contains a promise to fetch data 
> from the server, which is going to be stored in the $scope variable 
> inside the controller. The problem is that I need to access this variable 
> inside a <script> tag in the partial view file.
>
>
> Here's the code:
>
>
> *app.js*
>
> app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, 
> $urlRouterProvider){ 
>   .state('timeline', { 
>     url: '/timelines/:id', 
>     views: { 'partial-timeline': { 
>       templateUrl: 'partial/timeline.html', 
>       controller: 'TimelineController' } 
>     }, 
>     resolve: { 
>       getOneTimeline: ['$stateParams','timelineServ', function($stateParams, 
> timelineServ) { 
>         return timelineServ.getTimelineById($stateParams.id); 
>       }] 
>     } 
>   }); 
> }]); 
>
> app.controller('TimelineController', ['$scope', 'timelineServ', 
> function($scope, timelineServ) { 
>   $scope.timelineData = timelineServ.indivTimeline; 
> }]);
>
>
> *timeline.html*
>
> {{timelineData}} 
> <div id="timeline-embed" style="width: 100%; height: 600px"></div> 
>
> <script type="text/javascript"> 
>   window.timeline = new TL.Timeline('timeline-embed', {{timelineData}}); 
> </script>
>
>
> From the {{timelineData}} expression outside I can see that the variable 
> has the correct data however, as I said, I'm not able to use it inside the 
> <script> tags. 
>
> What is the best approach to solve this problem? I'm quite new to 
> AngularJS.
>
> Thank you in advance. Best Regards!
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to