在为对象分配值之前,如何防止计算ng-options?

时间:2015-12-04 07:09:29

标签: angularjs

我的应用中有代码:

ng-options="method.name for selectedHelp.methods in selectedHelp"

但是隐藏了整个选择标记,直到" selectedHelp"变量被赋值。我怎样才能防止ng-options计算,直到" selectedHelp"有价值吗?因为否则会引发错误。

1 个答案:

答案 0 :(得分:1)

使用class Program { static void Main(string[] args) { pl a ,b,c; a= new pl(); b=new pl(); a.mark=99; b.mark=10; c = a+b; if (c != b) Console.WriteLine("is not equal"); else Console.WriteLine("both are equal"); Console.WriteLine(c.mark); Console.ReadLine(); } } class pl { public int mark; public static pl operator+ ( pl a , pl b) // 1. here It Work's Perfectly At + overloading { pl mm = new pl(); mm.mark = a.mark + b.mark; return mm; } public static bool operator!= (pl m , pl n) // 2. unable to overload { if (m.mark != n.mark) return true; else return false; } } 隐藏ng-if,直到selectedHelp可用:

ng-options