我正在使用 AngularJS。 我正在尝试在 Controller.js 的函数内部使用 IF-Statement,但我不知道如何处理那里。
[尝试实现 IF 语句的代码]
ProjectService.getProject($stateParams.project_id)
.then(function(project) {
// if $stateParams.project_id exists, then execute ABC
// ABC..
// if no existence, then exit.
});
我试图搜索与我的相似的,但我找不到。 也许,如果在 AngularJS 的函数中不起作用?
有人可以帮助我吗?
提前谢谢您!!
最佳答案
就这样做:
ProjectService.getProject()
.then(function(project) {
if($stateParams.project_id){
// ABC..
}
});
希望有帮助。
关于AngularJS .. .then function() 中 IF 语句的可能性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47138856/