10 examples of 'get selected value of dropdown in angular 4' in JavaScript

Every line of 'get selected value of dropdown in angular 4' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
540public selectValue(value: any): void {
541 if (this.dropdown) {
542 this.ngZone.runOutsideAngular(() => {
543 this.dropdown.selectValue(value);
544 });
545 }
546}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

45public getSelectedValue(): any {
46 if (this.multiple && this.value.length === 1) {
47 return this.selectedDisplayValue(this.value[0]);
48 } else {
49 const index = this.options.findIndex(item => equal(this.value, item));
50 return index >= 0 ? this.selectedDisplayValue(this.options[index]) : undefined;
51 }
52}
68public displayValue(item): string {
69 return this.displayBy ? item[this.displayBy] : item;
70}
149public getViewValue(): string {
150 if (typeof this.$scope.ngModel !== 'undefined' && this.$scope.ngModel != null) {
151 return this.$scope.ngModel.$viewValue;
152 }
153}
48public get value() {
49 const { defaultValue } = this.props;
50 const { selected } = this.state;
51 return selected || defaultValue;
52}
286_setSelectedValues() {
287 this.selectedItem = this.shadowRoot.querySelector("#menu").selectedItem;
288 this.selectedItemLabel = this.shadowRoot.querySelector(
289 "#menu"
290 ).selectedItemLabel;
291 this.selectedItemIndex = this.shadowRoot.querySelector("#listbox").selected;
292}
32get selectedOptions() {
33 return this.model;
34}
225get HTMLValue() {
226 if (this.HTML !== undefined) {
227 if (this.HTML.options !== undefined) {
228 let index = this.HTML.selectedIndex
229 return this.HTML.options[index]
230 }
231 }
232 return undefined
233}
66getSelectedOption(key) {
67 return this.$refs.select2.options[this.selectedIndex()].dataset[key];
68}
39selectValue(e) {
40 const listNode = this.refs['valuesList'];
41 let target = e.target || e.srcElement;
42 let isli = false;
43 while(!isli && target != null) {
44 if(target.parentNode == listNode) {
45 isli = true;
46 break;
47 }
48 target = target.parentNode;
49 }
50
51 if(isli) {
52 const value = target.textContent;
53 const valueElement = this.refs['valueElement'];
54 if(valueElement['textContent'] != value) {
55 valueElement['textContent'] = value;
56 if(this.props.onValueChanged) {
57 this.props.onValueChanged(value);
58 }
59 }
60 }
61}

Related snippets