将函数传递给指令与属性值

时间:2017-04-17 15:40:25

标签: angularjs

如果我有一个具有属性的自定义指令:

$ uname -a
Darwin Michaels-Mac-mini 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan  9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64

$ python --version
Python 3.5.1 :: Anaconda 4.0.0 (x86_64)

$ transcrypt -h
Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.6.24
Copyright (C) Geatec Engineering. License: Apache 2.0

$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

$ transcrypt -b autotest.py 
Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.6.24
Copyright (C) Geatec Engineering. License: Apache 2.0

Saving result in: /Users/mellis/anaconda3/lib/python3.5/site-packages/transcrypt/development/automated_tests/transcrypt/__javascript__/autotest.js
Saving minified result in: /Users/mellis/anaconda3/lib/python3.5/site-packages/transcrypt/development/automated_tests/transcrypt/__javascript__/autotest.min.js
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CommandLineRunner : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Ready

将属性从控制器传递给指令并使用函数将该属性传递给指令,只要它们都传递相同的属性值,是否有任何区别?

<?php 
    $date = new DateTime();
    echo date_format($date,"m-d-y");
?>

我今天被告知在第二种情况下脏检查不能正常进行,我无法找到任何相应的效果。我试图理解为什么使用函数会干扰这里。

1 个答案:

答案 0 :(得分:1)

指令的范围有以下几种类型。

`@` Attribute string binding

`=` Two-way model binding

`&` Callback method binding

`<` One-way binding

当你将一个函数传递给指令的属性时,它的作用域的类型是字符串(即@),那么该函数解释为字符串。 有关详细信息,请参阅this link