无法使用angular访问对象属性

时间:2016-10-11 15:05:35

标签: angularjs

我无法在我的应用中访问我的对象属性。看起来这是一个控制器问题,但我从头开始两次,显然不是。

我的HTML如下:

2016-10-12 09:56:27,412 JavaFX Application Thread ERROR Unable to create file C:\\Users\\username\\AppData\\Local\\Temp\\/my_client.log java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:409)
    at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:391)
    at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:73)
    at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:81)
    at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:98)
    at org.apache.logging.log4j.core.appender.RollingFileAppender.createAppender(RollingFileAppender.java:191)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:491)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:561)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:551)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:537)
    at my_client.ui.MainApp.<clinit>(MainApp.java:40)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sun.javafx.applet.FXApplet2$1.call(FXApplet2.java:67)
    at com.sun.deploy.uitoolkit.impl.fx.FXPluginToolkit$Caller.run(FXPluginToolkit.java:347)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Unknown Source)

2016-10-12 09:56:27,415 JavaFX Application Thread ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile. java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:918)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:858)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:850)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:479)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:219)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:231)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:491)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:561)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:577)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:212)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:551)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:537)
    at my_client.ui.MainApp.<clinit>(MainApp.java:40)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sun.javafx.applet.FXApplet2$1.call(FXApplet2.java:67)
    at com.sun.deploy.uitoolkit.impl.fx.FXPluginToolkit$Caller.run(FXPluginToolkit.java:347)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@15bdc6b] unable to create manager for [C:\\Users\\username\\AppData\\Local\\Temp\\/my_client.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@dbdcaae[pattern=C:\\Users\\username\\AppData\\Local\\Temp\\/my_client-%d{yyyy-MM-dd}-%i.log, append=false, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[SizeBasedTriggeringPolicy(size=20971520)]), strategy=DefaultRolloverStrategy(min=1, max=1), advertiseURI=null, layout=%d{yyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36}::%M - %msg%n]]
    at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:75)
    at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:81)
    at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:98)
    at org.apache.logging.log4j.core.appender.RollingFileAppender.createAppender(RollingFileAppender.java:191)
    ... 35 more

2016-10-12 09:56:27,417 JavaFX Application Thread ERROR Null object returned for RollingFile in Appenders.
2016-10-12 09:56:27,422 JavaFX Application Thread ERROR Unable to locate appender "logfile" for logger config "root" 

我的控制器如下:

<table>
<thead>
    <th>Title</th>
    <th>URL</th>
</thead>
<tbody>
    <tr ng-repeat="movie in movies">
        <td>{{movie.title}}</td>
        <td>{{movie.url}}</td>
    </tr>
</tbody>
</table>

有什么想法吗?

我希望有:

http://howardhinnant.github.io/date_algorithms.html

它出现了:

Exepected result

提前致谢

2 个答案:

答案 0 :(得分:0)

您缺少模块的依赖项,并且您未在视图中的任何位置提及ng-controller

angular.module('clientApp',[])

DEMO

答案 1 :(得分:0)

您必须将应用程序和控制器引用到视图中,并使用正确的语法来引用模块。

这有点棘手,但您使用以下语法构建了一个模块:

angular.module('MODULE_NAME', [ /* Insert optional module dependency here */ ]);

您可以使用以下语法创建模块:

angular.module('MODULE_NAME').controller()

模块的创建似乎会返回模块本身,因此您也可以使用最简洁的语法:

angular.module('MODULE_NAME', []).controller()

这有点误导,因为您没有看到创建和使用之间的区别。并且必须警告执行两次此命令:angular.module('MODULE_NAME', [])将导致(非常常见)错误。

请参阅此工作示例:

&#13;
&#13;
// declare a module
var clientAppModule= angular.module('clientApp', []);

// configure the module.    
clientAppModule.controller('ClothesCtrl', function ($scope) {
$scope.clothes = [
     {
         name: 'T-shirt',
         description: 'Cool T-shirt'
     }
    ];
  });
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

    <table ng-app='clientApp'
           ng-controller='ClothesCtrl'>
    <thead>
        <th>Title</th>
        <th>URL</th>
    </thead>
    <tbody>
        <tr ng-repeat="cloth in clothes">
            <td>{{cloth.name}}</td>
            <td>{{cloth.description}}</td>
        </tr>
    </tbody>
    </table>
&#13;
&#13;
&#13;