I'm new in AngularJS, and I try to change ng-model dynamically based on ng-click parameter function. So here is the code :
HTML :
<ul class="dropdown-menu" id="search-dropdown-menu">
<li>
<a href="javascript:void(0);" data-ng-click="searchFilter('jurusan', '-')">
-
</a>
</li>
<li>
<a href="javascript:void(0);" data-ng-click="searchFilter('jurusan', 'kd_jurusan')">
Kode Jurusan
</a>
</li>
<li>
<a href="javascript:void(0);" data-ng-click="searchFilter('jurusan', 'nama_jurusan')">
Nama Jurusan
</a>
</li>
</ul>
<input type="text"
class="form-control input-sm"
data-ng-model="search"
placeholder="Cari data . . ."
autofocus />
AngularJS :
/**
* Controller
*/
akuaApp.controller('akuaController', function($scope)
{
$scope.searchFilter = function (model, value) {
$scope.search = 'search.'+value;
};
});
And that is being changed is on the input value, not the data-ng-model value. I tried to read all tutorials but I still did not get it about this. Can someone help me, thanks :)
EDITED : (sorry for my bad English)
So what I want is, lets say I click this
<a href="javascript:void(0);" data-ng-click="searchFilter('jurusan', 'nama_jurusan')">
Nama Jurusan
</a>
After I click that, I want this data-ng-model attribute value, from search into search.nama_jurusan. nama_jurusan is from searchFilter second parameter.
Note : I was put the data-ng-controller and data-ng-app before
And that is being changed is on the input value, not the data-ng-model valuein controller you don't get updated value??