Noble Noble - 1 year ago 63
AngularJS Question

How to show translation text in angularjs controller alert from json file?

I have a JSON file with translations, like this one:

"ALERT_MESSAGE" : "Select a row"


Now, I want to show an alert from my controller when the user try to access to a link without select a row.

$scope.goToNext = function () {
if($scope.isSelected === false){
alert("What should I put here?");
}
else{
Navigator.goTo("/next", {
back: "/previus",
asd: $scope.asd
});
}
};


How can I use my translations file on the controller?

Answer Source

Finally adding $filter to the controller and using it like here:

alert($filter('translate')('ALERT_MSG'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download