10 examples of 'ng-select angular 6' in JavaScript

Every line of 'ng-select angular 6' 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
563function ngSelectFactory(): NgSelectComponent {
564 return new NgSelectComponent(null, null, new NgSelectConfig(), () => new DefaultSelectionModel(), {} as any, null, null);
565}
85function NgSelectOption(_element, _renderer, _select) {
86 this._element = _element;
87 this._renderer = _renderer;
88 this._select = _select;
89 if (lang_1.isPresent(this._select))
90 this.id = this._select._registerOption();
91}
217ngAfterViewInit(): void {
218 this._cd.detectChanges();
219}
108ngOnInit() {
109 const state = this.dropdown.menu.state.dropdownState;
110
111 state.onItemClicked.subscribe(item => {
112 if (this.multiple) {
113 this.toggle(item.value);
114 } else {
115 this.value = this.multiple ? this.value : item.value;
116 }
117
118 this.onChange.emit(this.value);
119 });
120
121 this.dropdown.onShow.subscribe(() => {
122 if (!this.value) {
123 return;
124 }
125
126 // focus selected element
127 const index = this.findIndexValue(this.value);
128 const item = this.dropdown.menu.items.toArray()[index];
129
130 state.select(item, false);
131 });
132}
580function mdSelectOnFocusDirective() {
581
582 return {
583 restrict: 'A',
584 link: postLink
585 };
586
587 function postLink(scope, element, attr) {
588 if (element[0].nodeName !== 'INPUT' && element[0].nodeName !== "TEXTAREA") return;
589
590 element.on('focus', onFocus);
591
592 scope.$on('$destroy', function() {
593 element.off('focus', onFocus);
594 });
595
596 function onFocus() {
597 // Use HTMLInputElement#select to fix firefox select issues
598 element[0].select();
599 }
600 }
601}
212select: function select(index) {
213 var _this = this;
214
215 if (this.suggestions && this.suggestions[index]) {
216 this.$emit('input', this.suggestions[index].value);
217 this.$emit('select', this.suggestions[index]);
218 this.$nextTick(function () {
219 _this.hideSuggestions();
220 });
221 }
222 },
115ngAfterContentInit() {
116 let defaultOption: OptionComponent;
117 this.options.forEach((option: OptionComponent, index: number) => {
118 if (option.selected) {
119 defaultOption = option;
120 this.selectedIndex = index;
121 }
122 });
123 if (!defaultOption) {
124 defaultOption = this.options.toArray()[this.selectedIndex];
125 }
126 if (!defaultOption) {
127 defaultOption = this.options.first;
128 this.selectedIndex = 0;
129 }
130 if (defaultOption) {
131 this.value = defaultOption.value;
132 defaultOption.selected = true;
133 this.defaultOption = defaultOption;
134 }
135}
50link($scope, element, attrs) {
51 // defines property name
52 $scope.selectName = attrs.cheName;
53
54
55 // defines the first element as selected
56 if ($scope.$parent.$first) {
57 $scope.$parent.$parent[attrs.cheName + '.selecterSelected'] = attrs.cheTitle;
58 }
59
60
61}
51function viewTreeSelectDirectiveController($filter, $log, $state, $scope, $rootScope, $q, $uibModal, ngToast, webvellaCoreService,$timeout) {
52
53 $scope.isRecordSelected = function (nodeRecordId) {
54 return $scope.selectedTreeRecords.indexOf(nodeRecordId) > -1
55 }
56
57 $scope.isNodeSelectable = function (nodeId) {
58 return $scope.selectableNodeIds.indexOf(nodeId) > -1
59 }
60
61 $scope.isNodeCollapsed = function (nodeId) {
62 return $scope.collapsedTreeNodes.indexOf(nodeId) > -1
63 }
64
65 $scope.attachHoverEffectClass = {};
66
67 $scope.toggleNodeSelected = function (node) {
68 if ($scope.isNodeSelectable(node.id) || $scope.isRecordSelected(node.recordId)) {
69 $timeout(function(){
70 $rootScope.$emit("webvellaAdmin-toggleTreeNode-selected", node);
71 },0);
72 }
73 }
74
75 $scope.toggleNodeCollapse = function (node) {
76 $timeout(function(){
77 $rootScope.$emit("webvellaAdmin-toggleTreeNode-collapsed", node);
78 },0);
79 }
80
81
82}
99ngAfterViewInit() {
100 this.updateState();
101}

Related snippets