我想从JavaScript如何从javascript调用angularjs函数?
的JavaScript调用我的AngularJs功能
function loadData1() {
var dropdown = document.getElementById("dropdown");
var a = dropdown.options[dropdown.selectedIndex].value;
if (a=="organisationUnits") {
getorganisationUnits();
}
}
AngularJs
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
//angular.element('#myCtrl').scope().getorganisationUnits();
$scope.getorganisationUnits = function() {
window.alert("Show data");
}
});
HTML
<div ng-app="myApp" ng-controller="myCtrl" id="content">
<select id="dropdown">
<option value="selected"> Please Select Option</option>
<option value="organisationUnits"> Organisation Units</option>
</select>
<input type="button" value="Go" id="getall_go" onclick="loadData1()"></input>
</div>
这不是*角*的方式做这 – Weedoze
//angular.element(“#内容”)的范围( ).getorganisationUnits(); – Laurianti
@Laurianti这不是如何在AngularJS中工作。请为AngularJS提供正确的解决方案 – Weedoze