angular


How do I pass input parameters for a component when using mdl custom dialog?


Here is the tutorial code to create a custom dialog from the official angular-mdl website.
let pDialog = this.dialogService.showCustomDialog({
component: LoginDialogComponent,
providers: [{provide: TEST_VALUE, useValue: 'Just an example'}],
isModal: true,
styles: {'width': '350px'},
clickOutsideToClose: true
});
Now, if I add some #Input() parameters to LoginDialogComponent, e.g. #Input() requireCaptcha: boolean;
How can I pass parameters there?
You can't use #Input in your case because this would require an element where you can pass your requireCaptcha value.
The intention is to use the providers Array to pass values to your dialog component. First of all create an InjectionToken:
export const REQUIERE_CAPTCHA = new InjectionToken<boolean>('requireCaptcha');
Then in your showCustomDialog method use:
let pDialog = this.dialogService.showCustomDialog({
component: LoginDialogComponent,
providers: [{provide: REQUIERE_CAPTCHA, useValue: true}],
isModal: true,
styles: {'width': '350px'},
clickOutsideToClose: true
});
Now you can access the REQUIERE_CAPTCHA in your dialog component:
constructor(
private dialog: MdlDialogReference,
#Inject( REQUIERE_CAPTCHA) requireCaptcha: boolean) {
console.log(requireCaptcha);
}

Related Links

Opening menu using position, angular2 material
Undefined is not an object(evaluating) - angular
Font Awesome with Ionic2
angular view is not updating after component value gets changed
how do I merge the values of the child components of angular2 into reactive form object?
Angular2 multiple components different imports
Update an array with new objects
Dropbox service with popup
Sending Emails Using TinyMce- Angular 2
Nested form tags in angular 2
Toggle Value in Angular Material CheckBox
Angular2 cli error cannot resolve #angular animations from primeng2 components
ionic2 AlertController, how to return the buttons clicked value from method
Cannot read property 'stateChangeExpr' of null at _parseAnimationStateTransition
Angular2 : not able to install xml2json
Ionic 3 - Supplied parameters do not match any signature of call target

Categories

HOME
local-storage
veins
mongoose
zurb-foundation
reactor-netty
xhtml
terraform
css-modules
sourceforge
log4net
pthreads
angularjs-ng-route
fix
libreoffice-base
cassandra-cli
denial-of-service
prestashop-1.6
jxmaps
cloudify
firebase-cloud-messaging
pfsense
silex
frama-c
size-classes
pywavelets
remote-connections
android-logcat
povray
chmod
puma
street-address
free-jqgrid
citations
initializing
james
each
nsubstitute
nonetype
sap-bw
fluent-nhibernate
roc
grunt-string-replace
enterprise-library-6
ikvm
gear-vr
lab-color-space
release-management
android-7.1-nougat
mongodb-scala
apple-search-ads
gyp
svg-edit
turtle-rdf
unicorn
video-recording
dotpeek
throttle
codeigniter-restserver
nsolid
typing
grid-layout
gethostbyname
google-roads-api
mediafire
ng-template
httpful
octopress
tstringgrid
apache-commons
authentication-flows
fswatch
savefiledialog
resin
jquery-dynatree
unassigned-variable
jml
automapper-3
mux
tbb
webproxy
policies
avassetwriter
zebra-puzzle
yepnope
fluent-security
topcoat
postfix-operator
icommand
rdata
amber-smalltalk
operational-transform
incompatibletypeerror
git-add
abpeoplepickerview
scalaquery
stack-unwinding
cck
paint.net
open-basedir

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile