如何为我的ngif使用ng-for访问ng容器内的变量?

时间:2019-06-13 17:18:17

标签: angular angular7

我正在使用模板驱动的表单。我有一个ng容器,用于创建单选按钮。作为验证的一部分,我有一个变量名来检查错误。

下面是我的代码段:

class Foo:
    __slots__ = ('a', 'b')

    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __str__(self):
        return str(self.__dict__)

>>> str(Foo(1, 2))
AttributeError: 'Foo' object has no attribute '__dict__'

此目标是让底部的ngIf读取单选按钮的状态。在这种情况下,将有3个或4个不同的单选按钮。

目前,ngIf无法读取单选按钮变量。如何将单选按钮变量添加到ngIf?我不希望ngIf进入我的for循环。

1 个答案:

答案 0 :(得分:0)

将变量作为上下文传递给模板。试试这个

    use utf8;
    use open ':std', ':encoding(UTF-8)';
my $dbh = DBI->connect("dbi:mysql:".$dsn, $user, $password, {
   PrintError => 0,
   RaiseError => 1,
   mysql_enable_utf8 => 1,  # Switch to UTF-8 for communication and decode.
});
# or {mysql_enable_utf8mb4 => 1} if using utf8mb4