rnadler / ng2-password-strength-bar

Angular 2/4/5 Password Strength Bar
http://bobonmedicaldevicesoftware.com/blog/2016/12/09/publishing-an-angular-2-component-npm-package/
MIT License
20 stars 17 forks source link

ERROR TypeError: Cannot read property 'currentValue' of undefined #29

Closed bogdanbaghiu closed 3 years ago

bogdanbaghiu commented 3 years ago

Hello.

I am trying to change the barLabel tag based on the language. When I change from English to Spanish I should change "Password consistent" to "Password consistency" but it gives me the following error. I have observed that it looks if the currentValue of the password is var password = changes['passwordToCheck'].currentValue; It is seen that the passwordToCheck is undefined and cannot read currentValue.

EditUserPage.html:22 ERROR TypeError: Cannot read property 'currentValue' of undefined at PasswordStrengthBarComponent.push../node_modules/ng2-password-strength-bar/lib/passwordStrengthBar.component.js.PasswordStrengthBarComponent.ngOnChanges (passwordStrengthBar.component.js:77) at checkAndUpdateDirectiveInline (core.js:27784) at checkAndUpdateNodeInline (core.js:38472) at checkAndUpdateNode (core.js:38411) at debugCheckAndUpdateNode (core.js:39433) at debugCheckDirectivesFn (core.js:39376) at Object.eval [as updateDirectives] (EditUserPage.html:23) at Object.debugUpdateDirectives [as updateDirectives] (core.js:39364) at checkAndUpdateView (core.js:38376) at callViewAction (core.js:38742)

rnadler commented 3 years ago

If possible, can you please post the code that is setting the barLabel value? Thanks.

bogdanbaghiu commented 3 years ago

I have created a repository where I leave all the code necessary to reproduce the error: https://github.com/bogdanbaghiu/test-ng2-password-checker

rnadler commented 3 years ago

@bogdanbaghiu Thanks for the usage example. Parameter changes also trigger the ngOnChange event and your PR resolves this bug. Please see bogdanbaghiu-master changes where I've simplified the logic change and added a test that reproduces the issue.

I will merge these changes and push a new NPM version (v1.2.5).

bogdanbaghiu commented 3 years ago

@rnadler Thanks for fixing it :) regards

rnadler commented 3 years ago

Just published v1.2.5 to NPM. Give it a try and let me know if you have any issues. Thanks!