How to use ng-bind on a td tag?

I have the following <td> element

<td translate="Price-{{product-op}} {{product-np}}" translate-values=GetVal()></td>

Now, GetVal() function is potentially dangerous because it is in a third party app.

So, I have decided to strip off any malicious elements. Decided to use ng-bind

The problem is how to ng-bind and then translate in the above code?

I came up with something like,

<td ng-bind translate="Price-{{product-op}} {{product-np}}" translate-values=GetVal()></td>

but it throws angular exception.

Any ideas ?

Upvotes: 0

Views: 1438

Answers (2)

Renato Ferreira
Renato Ferreira

Reputation: 1

I don't understood exactly what do you want to do, But I imagine that the exception is because the 'ng-bind' prop needs a value to do a bind like this:

<script>
  angular.module('bindExample', [])
    .controller('ExampleController', ['$scope', function($scope) {
      $scope.name = 'Whirled';
    }]);
</script>

<div ng-controller="ExampleController">
  <label>Enter name: <input type="text" ng-model="name"></label><br>
  Hello <span ng-bind="name"></span>!
</div>

Upvotes: 0

Vladimir Zdenek
Vladimir Zdenek

Reputation: 2290

If you are using the Angular Translate library (https://angular-translate.github.io), the translate directive should bind the value automatically. If you remove the ng-bind, it should work.

But I am not sure what library you are using for your translations, so my suggestion might not help you. You might have to provide more information.

Also ng-bind requires a value in the $scope - for example put $scope.myValue = 'My Value' in your controller and then use this in your HTML <td ng-bind="myValue"></td>. But again, I do not know what the translate directive is supposed to do.

Upvotes: 1

Related Questions