Remove useless data/event binding on i18n directive.

stable
Andrey Antukh 2014-10-10 00:22:48 +02:00
parent 781f31a4cb
commit d145e272f7
1 changed files with 7 additions and 11 deletions

View File

@ -53,18 +53,14 @@ I18nDirective = ($rootscope, $i18n) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
values = $attrs.tr.split(",") values = $attrs.tr.split(",")
options = $attrs.trOpts or '{}' options = $attrs.trOpts or '{}'
applyTranslation = ->
opts = $scope.$eval(options) opts = $scope.$eval(options)
for v in values for v in values
if v.indexOf(":") == -1 if v.indexOf(":") == -1
$el.html(_.escape($scope.t(v, opts))) $el.html(_.escape($i18n.t(v, opts)))
else else
[ns, v] = v.split(":") [ns, v] = v.split(":")
$el.attr(ns, _.escape($scope.t(v, opts))) $el.attr(ns, _.escape($i18n.t(v, opts)))
bindOnce($scope, "t", applyTranslation)
$scope.$on("i18n:changeLang", applyTranslation)
return { return {
link: link link: link