Ng-click and ng-change aren't being fired when using component and template angular 1.6 -
i trying fire function when typed input. reason, not working when use template , component. can me figure out why happening? new angular way.
component when button clicked or when typed input, ng-click , ng-change functions should fire not.
(function(angular) { 'use strict'; angular .module('app') .component('coinsearch', { controller: coinsearchcontroller, controllaras: 'coin', templateurl: 'src/coinsearch.html' }); function coinsearchcontroller(cryptoservice) { var coin = this; var list = []; coin.jank="something weird"; coin.savedcoins = []; coin.searchedcoin = ''; function getcrypto() { //pulls data api cryptoservice .retrieve() .then(function(response) { coin.list = response; }); } coin.click = function() { console.log('hellooo'); }; coin.showsearch = function() { console.log('hello'); return coin.searchedcoin === ''; }; getcrypto(); } })(angular);
template template component above. there console.logs testing purposes.
<div class="container"> <form class="search-form"> <button ng-click="coin.click()">{{coin.jank}} </button> //testing <input type="text" class="search" placeholder="search crypto" ng-model="coin.searchedcoin" ng-change="coin.showsearch()"> <ul class="suggestions"> <li ng-hide="coin.showsearch()" ng-repeat="coins in coin.list | filter:coin.searchedcoin"> <span>{{coins.name}} ({{coins.symbol}})</span> <span>${{coins.price_usd}}</span> <span><button ng- click="coin.addtolist(coins);">add</button></span> </li> </ul> </form> <coin-list></coin-list> </div>
if @ controlleras
statement, have spelled controllaras
. explain why nothing listening in template when use coin
.
Comments
Post a Comment