Reputation: 410
I use Jquery plugin bootstrapCheckboxes. So, these checkboxes I create inside Angular JS function:
$scope.createDropDownList = function (element, data, title) {
$(element).dropdownCheckbox({
data: data,
autosearch: true,
hideHeader: false,
showNbSelected: true,
templateButton: '<a class="dropdown-checkbox-toggle" data-toggle="dropdown" href="#"><span>' + title + '</span> <span class="dropdown-checkbox-nbselected"></span><b class="caret"></b></button>'
});
}
It works and dropdown list appears on page with checkboxes -one of them:
<input type="checkbox" required="" value="1" ng-click="selectType(1, $event)">
You can see event ng-click(selectType(1, $event))
.
At Angular JS I have this method:
$scope.function = selectType(){
alert('done');
}
But after click I dont get alert message and other errors in console. What may cause?
Upvotes: 0
Views: 157
Reputation:
The html you see <input type="checkbox" required="" value="1" ng-click="selectType(1, $event)">
is not compiled against the angular scope, it is generated (somehow) by the jQuery plugin, so the angular is not aware that you placed a ng-click
on the element, therefore nothing happens when you click it. If a fiddle will be provided, I'll try to provide an working solution.
Upvotes: 1
Reputation: 3560
That is not right method to define click event using Angular.js.
It is something like below In your js file write the below function.
function your_controller_name($scope){
$scope.selectType=function(){
alert("done").
}
}
Link this js file in your html page and your_controller_name stand for what you have set in ng-controller.
Upvotes: 0