Skip to content

add change events#62

Merged
mseemann merged 1 commit into
mseemann:masterfrom
tb:add-change-events
Sep 5, 2016
Merged

add change events#62
mseemann merged 1 commit into
mseemann:masterfrom
tb:add-change-events

Conversation

@tb

@tb tb commented Sep 5, 2016

Copy link
Copy Markdown
Contributor

No description provided.

@tb

tb commented Sep 5, 2016

Copy link
Copy Markdown
Contributor Author

I have been testing the code with

export class ToggleDemo extends AbstractDemoComponent {
  //...

  onChange(value) {
    console.log('Changed value to', value);
  }
}

And

<mdl-checkbox  [mdl-ripple]="true" [(ngModel)]="checkbox1" (change)="onChange($event)">Checkbox</mdl-checkbox>
<mdl-radio name="group1" value="1" [(ngModel)]="radioOption" (change)="onChange($event)" mdl-ripple>Value 1</mdl-radio>
<mdl-radio name="group1" value="2" [(ngModel)]="radioOption" (change)="onChange($event)" mdl-ripple>Value 2</mdl-radio>
<mdl-icon-toggle  [(ngModel)]="checkbox1" (change)="onChange($event)" mdl-ripple>format_bold</mdl-icon-toggle>
<mdl-icon-toggle  [(ngModel)]="checkbox2" (change)="onChange($event)">format_italic</mdl-icon-toggle>
<mdl-switch [(ngModel)]="checkbox1" mdl-ripple (change)="onChange($event)">Option 1</mdl-switch>
<mdl-switch  [(ngModel)]="checkbox2" (change)="onChange($event)">Option 2</mdl-switch>

@tb

tb commented Sep 5, 2016

Copy link
Copy Markdown
Contributor Author

I tried to write tests, but have problems with running them:

➜  angular2-mdl git:(add-change-events) ✗ npm test

> angular2-mdl@1.5.0 test /Users/tb/projects/ng2/angular2-mdl
> ng version; tsc -v; ng test --watch false

Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.10
node: 5.4.1
os: darwin x64
Version 2.0.2
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
Built project successfully. Stored in "dist/".
Cannot find module './lib/js-yaml.js'
Error: Cannot find module './lib/js-yaml.js'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/node_modules/js-yaml/index.js:4:12)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/lib/config.js:10:12)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/lib/command/check-coverage.js:15:21)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
05 09 2016 17:25:56.750:ERROR [config]: Error in config file!
 [Error: Could not register command from file check-coverage.js]
Error: Could not register command from file check-coverage.js
    at /Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/lib/util/factory.js:60:27
    at Array.forEach (native)
    at Object.Factory.loadStandard (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/lib/util/factory.js:53:29)
    at Object.<anonymous> (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/lib/register-plugins.js:12:9)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/node_modules/istanbul/index.js:13:1)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/tb/projects/ng2/angular2-mdl/node_modules/karma-coverage/lib/index.js:8:1)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
npm ERR! Test failed.  See above for more details.

'[class.is-upgraded]': 'true',
'[class.is-checked]': 'value'
},
outputs: ['change'],

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you can delete this line safely. it is inherited from the checkbox component. the same way as inputs: ['value'], works

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it, change is not emited.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let it in there i'll take a look after the merge.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like I get duplicate events - one from the mdl-checkbox which delivers true or false and another from the input element itself emitting a full $event object.
Maybe consider to rename the change event name to something different?

@mseemann

mseemann commented Sep 5, 2016

Copy link
Copy Markdown
Owner

Hi thanks for your work! can you edit the radio component like i suggest in comment and rebase your branch so i can merge the pull request automatically? I'll add the tests. Don't know whats going wrong there. Thx!

@tb tb force-pushed the add-change-events branch from 8514a8e to cedf9b4 Compare September 5, 2016 15:37
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.0009%) to 99.699% when pulling cedf9b4 on tb:add-change-events into 1b4d3f1 on mseemann:master.

@mseemann mseemann merged commit f52bcc5 into mseemann:master Sep 5, 2016
@mseemann

mseemann commented Sep 5, 2016

Copy link
Copy Markdown
Owner

published in pm v 1.5.1 Thanks @tb 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants