Skip to content
This repository has been archived by the owner on Nov 14, 2017. It is now read-only.

support bem-components #7

Open
Guria opened this issue Apr 10, 2015 · 4 comments
Open

support bem-components #7

Guria opened this issue Apr 10, 2015 · 4 comments

Comments

@Guria
Copy link

Guria commented Apr 10, 2015

Define directive in template for each block from bem-components.
In directives:

Maybe it should be implemented in separate repo.

@awinogradov
Copy link
Owner

@Guria i think about this. Thanks!

@Guria
Copy link
Author

Guria commented May 8, 2015

working example for input:

modules.define('angular-bem', ['jquery'], function(provide, $, ngBem) {
    provide(ngBem.directive('inputAngular', function() {
        return {
            restrict : 'C',
            require : '?ngModel',
            link : function(scope, element, attrs, ngModel) {
                if(!ngModel) return;

                var input = $(element).bem('input');

                ngModel.$render = function() {
                    input.setVal(ngModel.$viewValue || '');
                };

                input.on('change', function() {
                    scope.$evalAsync(read);
                });

                read();

                function read() {
                    ngModel.$setViewValue(input.getVal());
                }
            }
        }
    }));
});

@awinogradov
Copy link
Owner

Cool!!!

@Guria
Copy link
Author

Guria commented May 12, 2015

We can list here bem-components blocks that need such directives.

  • input
  • attach
  • checkbox
  • checkbox-group
  • menu
  • menu-item
  • radio
  • radio-group
  • progressbar
  • select

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants