This question already has answers here:
Ternary operator in AngularJS templates
                                
                                    (7个答案)
                                
                        
                                5年前关闭。
            
                    
是否可以在AngularJS的ng-init中使用三元运算符?

类似于:<select ng-model="project" name="act" ng-options="act.user_id as act.user_display_name for act in actors" ng-init="isLoggedIn == true ? "" : act.user_id = credentials.user_id" ></select>

最佳答案

是的,有可能。这是一个非常简单的演示:

http://jsbin.com/wobayovi/1/edit?html,output

关于javascript - 如何在AngularJS的ng-init中使用三进制? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24936858/

10-13 04:15