material icon indicating copy to clipboard operation
material copied to clipboard

md-tab's label has only one-time binding

Open gitawego opened this issue 11 years ago • 7 comments

with this code:

<md-tab label="{{ 'WEAK_POINTS' | translate }}">

tab title is converted to (without ng-binding):

<span class="ng-scope">Weak points</span>

if I change the language, tab title doesn't change the translation.

gitawego avatar May 15 '15 14:05 gitawego

I think you mean has a scope isolation (one way binding)?

bonatoc avatar May 17 '15 01:05 bonatoc

yes It's one way binding, I just checked the code (line 62):

scope: {
      label:    '@',
      active:   '=?mdActive',
      disabled: '=?ngDisabled',
      select:   '&?mdOnSelect',
      deselect: '&?mdOnDeselect'
    },

and line 76:

 data = ctrl.insertTab({
          scope:    scope,
          parent:   scope.$parent,
          index:    index,
          template: getTemplate(),
          label:    getLabel()
        }, index);

label doesn't have two way binding, nor $scope.$watch for label (only for 'active','disabled' and tab item)

gitawego avatar May 17 '15 17:05 gitawego

The way I do it :

<md-tab-label>
    <span ng-bind-html="str_Name | translate"></span>
</md-tab-label>

you may want to alter the span or div inside the md-tab-label, so it covers all surface. You can hack the label to be a flexbox, remove all paddings/margins and stretch the span inside.

bonatoc avatar May 17 '15 21:05 bonatoc

thanks for the hint, didn't know we could use tag "md-tab-label" ^^ but it's still a bug IMO.

gitawego avatar May 17 '15 21:05 gitawego

Not a bug : You're not supposed to tie angular-translate to the angular-material directive, which is a module that has nothing to do with angular-material.

I think that's why they built the encapsulated system, so we could fill the md-tab-labels, md-tab-items and the md-tab-contents with whatever html we want (filter and directives included).

Don't forget to use md-tab-body.

bonatoc avatar May 18 '15 12:05 bonatoc

@bonatoc won't get run time translated, but md-tab-body does.

rickli1989 avatar Jun 02 '15 01:06 rickli1989

I think it's a bug. Fix it please

franciscopuyo avatar Jun 08 '15 21:06 franciscopuyo