我有一个简单的 javascript 函数display(str)
,我想在里面调用它ng-if
。此功能不在控制器范围内
HTML
<body ng-app="myApp">
<div id="mycntrl" ng-controller="mainController">
<select id="selectid1" name="selectid1" ng-model="angularselect">
<option ng-value=""></option>
<option ng-value="val1">Value 1</option>
<option ng-value="val2">Value 2</option>
</select> Value : {{angularselect}}
<div ng-if="display(angularselect) === true">
<p>
Returned true
</p>
</div>
</div>
</body>
JS
var myApp = angular.module('myApp',[]);
myApp.controller('mainController',function($scope){
});
function display(str)
{
console.log('Javascript function called with argument '+str);
return true;
}