1
我將一個項目從角到Web組件/自定義元素,我試圖通過創建下列文本域綁定,以取代ng-model
:因爲這訪問屬性
<input type="search" class="form-control search_input" placeholder="Search for someone new" value$="[[userLookup:input]]" required autocomplete="off">
顯然從角轉換,我需要能夠在一個JavaScript函數來訪問該值:從lookupUser
FUNC內
(function(customElements) {
class RecentSearch extends PolymerMixins.LightDomMixin(Polymer.Element) {
static get is() { return 'recent-search'; }
static get properties() {
return {
properties: {
user: {
type: Object
},
userLookup: {
type: String,
reflectToAttribute: true,
value: '',
},
},
};
}
lookupUser() {
if (this.userlookup) {
$state.go('users', { query: userlookup });
}
};
}
customElements.define(RecentSearch.is, RecentSearch);
})(window.customElements);
我將如何訪問userLookup
屬性(在一個綁定到文本字段)重刑?