html - Using AngularJS 1.2.16, unique issue with data escaping for href links -
having issues ng-href can use target="_blank" using angularjs 1.2 ,old post found going on leading me question,i have page has table inside accordian, in js file have angular functions , have this:
var capitalrequestmultimillinquirycontroller = function ($scope, $rootscope, $modal, $window, capitalrequestservice, plantservice) { $rootscope.title = 'capital request multi mill inquiry'; $scope.allmills = []; $scope.selectedmill = ''; $scope.jobnumber = ''; $scope.description = ''; $scope.amount = ''; $scope.amountoperator = ''; $scope.openonly = ''; $scope.projectmanager = ''; //$scope.allusers = []; //usersservice.getuserswithid().then(function(objecttypes) { // $scope.allusers = objecttypes //}); //$scope.openurl = function() { // $scope.openurl = function(url) { // $location.path(url, '_blank') // } //} plantservice.getplantid().then(function (mills) { $scope.allmills = mills }); $scope.search = function() { //for each mill capitalrequestservice.searchmulti("http://coucmmsweb.pca.com/capitalrequest/search", authenticateduser.username.touppercase(), $scope.selectedmill, $scope.jobnumber, $scope.description, $scope.amount, $scope.amountoperator, $scope.openonly, $scope.projectmanager).then(function (results) { $scope.counce = results; }); capitalrequestservice.searchmulti("http://filcmmsweb.pca.com/capitalrequest/search", authenticateduser.username.touppercase(), $scope.selectedmill, $scope.jobnumber, $scope.description, $scope.amount, $scope.amountoperator, $scope.openonly, $scope.projectmanager).then(function (results) { $scope.filer = results; }); capitalrequestservice.searchmulti("http://tomcmmsweb.pca.com/capitalrequest/search", authenticateduser.username.touppercase(), $scope.selectedmill, $scope.jobnumber, $scope.description, $scope.amount, $scope.amountoperator, $scope.openonly, $scope.projectmanager).then(function (results) { $scope.tomahawk= results; }); capitalrequestservice.searchmulti("http://tridentval.pca.com/api/inquiry/inquiry/capitalrequestmultimillinquiry/search", authenticateduser.username.touppercase(), $scope.selectedmill, $scope.jobnumber, $scope.description, $scope.amount, $scope.amountoperator, $scope.openonly, $scope.projectmanager).then(function (results) { $scope.valdosta = results; }); capitalrequestservice.searchmulti("http://tridentder.pca.com/api/inquiry/inquiry/capitalrequestmultimillinquiry/search", authenticateduser.username.touppercase(), $scope.selectedmill, $scope.jobnumber, $scope.description, $scope.amount, $scope.amountoperator, $scope.openonly, $scope.projectmanager).then(function (results) { $scope.deridder = results; }); } };
and html page have this:
<tbody> <tr ng-repeat="item in tomahawk"> <td>{{item.projectmanager}}</td> <td>{{item.jobnumber}}</td> <td>{{item.description}}</td> <td>{{item.totalamount*1000 | currency}}</td> </tr> </tbody> </table>
and still have in view leads me believe url getting information has anchor tag isnt displaying data correctly because using angular on end. how escape angular contraints href's such data display , clickable download picture on next page? posted post earlier , thought end. remover , saw still returning anchor tag in display means source , pushing me. picture below older picture not clickable when take out of app on end, leaving table pulling in data.
you'll need let angular know data have trusted html, , bind td
elements.
in controller, you'll need use $sce
replace html trusted html:
capitalrequestservice.searchmulti("http://tomcmmsweb.pca.com/capitalrequest/search", authenticateduser.username.touppercase(), $scope.selectedmill, $scope.jobnumber, $scope.description, $scope.amount, $scope.amountoperator, $scope.openonly, $scope.projectmanager).then(function (results) { $scope.tomahawk = results; $scope.tomahawk.foreach(function(item){ item.jobnumber = $sce.trustashtml(item.jobnumber); item.description = $sce.trustashtml(item.description); }); });
and in view
<tbody> <tr ng-repeat="item in tomahawk"> <td>{{item.projectmanager}}</td> <td ng-bind-html="item.jobnumber"></td> <td ng-bind-html="item.description"></td> <td>{{item.totalamount*1000 | currency}}</td> </tr> </tbody> </table>
edit: changed for-loop foreach iteration, because seems little cleaner. check edit history if want way before.
Comments
Post a Comment