Browser-sync: ngModel not updated when change input forms

Created on 26 May 2016  路  2Comments  路  Source: BrowserSync/browser-sync

Issue details

Using browsersync with Angular SPA, when type on text input the view (not viewModel) are updated but the model not.

Steps to reproduce/test case

Use browsersync on Angular SPA with a form and type on inputs. Print the model on the html for view if these are updated or not.

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.12.8 ]
  • Node [ 6.0.0 ]
  • Npm [ 3.8.6 ]

    Affected platforms

  • [ ] linux

  • [ ] windows
  • [x] OS X
  • [ ] freebsd
  • [ ] solaris
  • [ ] other _(please specify which)_

    Browsersync use-case

  • [ ] API

  • [ ] Gulp
  • [x] Grunt
  • [ ] CLI

    for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

        browserSync: {
            dev: {
                bsFiles: {
                    src : '**/*.*'
                },
                options: {
                    watchTask: true,
                    proxy: 'localhost:8080/app',
                    plugins: [
                        {
                            module: "bs-html-injector",
                            options: {
                                files: '**/*.tpl.html'
                            }
                        }
                    ]
                }
            }
        }

Most helpful comment

I have same problem here

All 2 comments

I have same problem here

I had the same problem. I was able to get it working for Angular 1.x by making few changes to index.min.js in browser-sync-client module.

Line #1185

exports.socketEvent = function (bs) {

    return function (data) {

        if (!bs.canSync(data, OPT_PATH)) {
            return false;
        }

        var elem = bs.utils.getSingleElement(data.tagName, data.index);

        if (elem) {
           /* Check for Angularjs Application and trigger the event */
            if(angular){
                var ngElement = angular.element(elem);
                ngElement.val(data.value);
                ngElement.triggerHandler('input');
            }else{
                elem.value = data.value;    
            }

            return elem;
        }
        return false;
    };
};
Was this page helpful?
0 / 5 - 0 ratings