Angular2如何监听类中数据的更改?

时间:2016-04-13 19:08:41

标签: angular

我有一个包含类User的数组。此数组通过*ngFor呈现为重复的<li>项。用户可以单击这些项目并在详细控件中获取用户的详细信息。

详细控件中的字段使用[(ngModel)]绑定。

我试图弄清楚如何检测用户何时更改了特定用户中的数据,以便我可以将其标记为脏并且仅将修改后的用户发送回Web服务。我还想阻止用户导航未保存的数据。

在C#中,我将使用INotifyPropertyChanged接口来完成此任务。

我一直在关注ngOnChangesonchange,但这些似乎并不是我想要的。

任何帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

如果对编辑用户的输入字段使用[Host Controller] 09:28:18,462 INFO [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010922: Starting server server-one 09:28:18,512 INFO [org.jboss.as.process.Server:server-one.status] (ProcessController-threads - 3) JBAS012017: Starting process 'Server:server-one' [Server:server-one] Could not load Logmanager "/application/jboss/modules/org/jboss/logmanager/main/jboss-logmanager-1.5.2.Final.jar" [Server:server-one] java.lang.ClassNotFoundException: /application/jboss/modules/org/jboss/logmanager/main/jboss-logmanager-1.5.2.Final.jar [Server:server-one] at java.net.URLClassLoader$1.run(URLClassLoader.java:366) [Server:server-one] at java.net.URLClassLoader$1.run(URLClassLoader.java:355) [Server:server-one] at java.security.AccessController.doPrivileged(Native Method) [Server:server-one] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [Server:server-one] at java.lang.ClassLoader.loadClass(ClassLoader.java:425) [Server:server-one] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [Server:server-one] at java.lang.ClassLoader.loadClass(ClassLoader.java:358) [Server:server-one] at java.util.logging.LogManager$1.run(LogManager.java:191) [Server:server-one] at java.security.AccessController.doPrivileged(Native Method) [Server:server-one] at java.util.logging.LogManager.<clinit>(LogManager.java:181) [Server:server-one] at java.util.logging.Logger.demandLogger(Logger.java:339) [Server:server-one] at java.util.logging.Logger.getLogger(Logger.java:393) [Server:server-one] at com.sun.jmx.remote.util.ClassLogger.<init>(ClassLogger.java:55) [Server:server-one] at sun.management.jmxremote.ConnectorBootstrap.<clinit>(ConnectorBootstrap.java:823) [Server:server-one] at sun.management.Agent.startAgent(Agent.java:260) [Server:server-one] at sun.management.Agent.startAgent(Agent.java:456) [Server:server-one] WARNING: Failed to load the specified log manager class org.jboss.logmanager.LogManager [Server:server-one] Exception in thread "main" java.lang.IllegalStateException: The LogManager was not properly installed (you must set the "java.util.logging.manager" system property to "org.jboss.logmanager.LogManager") [Server:server-one] at org.jboss.logmanager.Logger.getLogger(Logger.java:61) [Server:server-one] at org.jboss.as.server.DomainServerMain.main(DomainServerMain.java:86) [Server:server-one] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [Server:server-one] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [Server:server-one] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [Server:server-one] at java.lang.reflect.Method.invoke(Method.java:606) [Server:server-one] at org.jboss.modules.Module.run(Module.java:312) [Server:server-one] at org.jboss.modules.Main.main(Main.java:460) 09:28:19,384 INFO [org.jboss.as.process.Server:server-one.status] (reaper for Server:server-one) JBAS012010: Process 'Server:server-one' finished with an exit status of 1 ,则表单会提供有关是否更改内容的信息。