【发布时间】:2016-06-02 12:27:38
【问题描述】:
我编写了一个在两个 div 元素之间切换的简单 javascript 函数。像这样:
function goToResults() {
document.getElementById("services").style.display = "none";
document.getElementById("results").style.display = "block";
}
在学习 Angular 时,我想将其转换为 app.js 中的 Angular 函数。我可以执行以下操作吗?
$scope.goToResults = function () {
$scope.getElementById("services").style.display = "none";
$scope.getElementById("results").style.display = "block";
}
谢谢!
【问题讨论】:
-
使用指令进行 DOM 操作。检查ng-style
-
请查看文档左侧菜单中的所有核心指令。有很多可以做到这一点...
ng-style...ng-class...ng-if..ng-show...ng-hide...ng-switch.... 都被驱动了根据您的数据模型
标签: javascript jquery angularjs angularjs-scope