I'm attempting to load a custom script from the database based on client-side logic. I am having trouble figuring out how to make it function properly.
Here is my controller code:
'use strict';
angular.module('youshareApp')
.controller('ShareCtrl',['$scope','$routeParams' ,'Projectservice',function ($scope,$routeParams,Projectservice) {
$scope.projectId=$routeParams.projectId;
$scope.model.url="/api/v1/project/code/"+$scope.projectId;
...
}]);
This is how my view looks:
<div class="container" ng-controller="ShareCtrl" style="margin-top: 50px;" >
<h3>You are currently contributing to : </h3>
<div class="row" style="margin-top: 10px;">
<div class="col-md-6"><label class="lead">{{model.name}}</label></div>
</div>
<div class="row" style="margin-top: 10px;">
<div class="col-md-6"><p class="lead" >{{model.description}}</p></div>
</div>
<script ng-src={{model.url}} />
</div>
Any suggestions on how to get this working?
I've also looked at this post
Using this template snippet:
<div html-bind-unsafe='html'></div>
And including this in the Controller:
$scope.html='<script src="'+$scope.model.url+'" />';