标签: javascript angularjs angularjs-scope
是否可以在AngularJS的ng-init中使用三元运算符?
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>
<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>
答案 0 :(得分:8)
是的,这是可能的。这是一个非常简单的演示:
http://jsbin.com/wobayovi/1/edit?html,output