Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Cannot set property 'backdrop' of undefined #217

Open
ramuse opened this issue Nov 11, 2017 · 12 comments
Open

Cannot set property 'backdrop' of undefined #217

ramuse opened this issue Nov 11, 2017 · 12 comments

Comments

@ramuse
Copy link

ramuse commented Nov 11, 2017

I get this error:

ERROR TypeError: Cannot set property 'backdrop' of undefined
at BsModalComponent.setOptions (ng2-bs3-modal.umd.js:122)
at BsModalComponent.ngOnChanges (ng2-bs3-modal.umd.js:165)
at checkAndUpdateDirectiveInline (core.js:12091)
at checkAndUpdateNodeInline (core.js:13597)
at checkAndUpdateNode (core.js:13540)
at debugCheckAndUpdateNode (core.js:14412)
at debugCheckDirectivesFn (core.js:14353)
at Object.View_xxx_0._co [as updateDirectives] (xxx.html:103)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14338)
at checkAndUpdateView (core.js:13507)

The problem occurs at line _this.options.backdrop = backdrop:

this.setOptions = function (options) {
	var backdrop = options.backdrop;
	if (typeof backdrop === 'string' && backdrop !== 'static')
		backdrop = true;
	if (options.backdrop !== undefined)
		_this.options.backdrop = backdrop;
	if (options.keyboard !== undefined)
		_this.options.keyboard = options.keyboard;
};

Suggestion for a fix:

this.setOptions = function (options) {
	var backdrop = options.backdrop;
	if (typeof backdrop === 'string' && backdrop !== 'static')
		backdrop = true;
	if (_this.options) {
		if (options.backdrop !== undefined)
			_this.options.backdrop = backdrop;
		if (options.keyboard !== undefined)
			_this.options.keyboard = options.keyboard;
	}
};
@dougludlow
Copy link
Owner

dougludlow commented Nov 11, 2017

It sounds like you're maybe setting the backdrop attribute like this:

[backdrop]="static"

Which is looking for a property on your component called "static", which is undefined.

You need to set the backdrop attribute like either

backdrop="static"

or

[backdrop]="'static'"

Which will pass the string "static" to the modal component.

See Static Modal in the readme for an example.

@amitdahan
Copy link

I'm having the same issue, I'm using it as [backdrop]="false" which should work.
I believe the author has the same issue. this.options doesn't exist hence the error.

@dougludlow dougludlow reopened this Nov 12, 2017
@dougludlow
Copy link
Owner

Looks like I need to add some tests around this... I'll take a look. Thanks for the detail @amitdahan.

@amitdahan
Copy link

Just confirmed this happened to me when I was using ng2-bs3-modal along with [email protected]

@kcadella
Copy link

kcadella commented Dec 7, 2017

I tried doing the samething but error. I am using "bootstrap": "^4.0.0-beta.2

@amitdahan
Copy link

This package shouldn't work with bs4, hence the name I guess

@kcadella
Copy link

kcadella commented Dec 8, 2017

I had it working with alpha till I upgraded to angular5 and got the latest version of this. I believe < .11 was working for me.

@kcadella
Copy link

kcadella commented Dec 8, 2017

.10.4 specifically.. trying to rollback and see if it still works with angular5 and BS4 Beta

@lewis-as
Copy link

Was there any update on this as the error still seems to be present with angular 5 and BS4

@amitdahan
Copy link

This package shouldn't work with bs4, hence the name I guess

@servehermans
Copy link

This issue is still happening. Any update? I am setting the [backdrop]="'static'" and receive the same error

@lewis-as
Copy link

lewis-as commented Nov 15, 2018 via email

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

6 participants