Angularjs 将angularMoment库注入Meanjs angular应用程序
尝试使用角力矩库。(不确定是否可以在此处添加链接)。试图使用它,如github repo所示。将库添加到索引文件、矩、角矩,然后Angularjs 将angularMoment库注入Meanjs angular应用程序,angularjs,mean-stack,angular-moment,Angularjs,Mean Stack,Angular Moment,尝试使用角力矩库。(不确定是否可以在此处添加链接)。试图使用它,如github repo所示。将库添加到索引文件、矩、角矩,然后 angular.module('chat', ['angularMoment']) .controller('ChatController', ['$scope', '$location', '$timeout', '$interval', '$filter', 'Authentication', 'Socket', 'Chat', function($sco
angular.module('chat', ['angularMoment'])
.controller('ChatController', ['$scope', '$location', '$timeout', '$interval', '$filter', 'Authentication', 'Socket', 'Chat',
function($scope, $location, $timeout, $interval, $filter, Authentication, Socket, Chat) {
}]);
但是如果我尝试将它注入myApp,整个控制器就会消失,就像它不在那里一样。我想它可能无法解决这个问题,而将整个控制器抛在了后面。尝试将其注入控制器,但返回找不到angularMomentProvider
im使用此控制器的视图:
<section ng-controller="ChatController" ng-init="getMessages()">
<div class="page-header">
<h1>Chat</h1>
</div>
<div class="col-md-4">asd</div>
<div class="col-md-6" style="background-color: hsla(30, 1%, 52%, 0.02); border-radius: 1%;">
<small>{{ userWriting }}</small>
<div scroll-to="isAtTop" style="padding: 10px 10px 0px; ">
<ul class="list-unstyled">
<li class="" ng-repeat="message in messages">
<small class="pull-right text-muted" style="color: lightgrey;"><span class="glyphicon glyphicon-time"></span> {{ message.created | timeDuration }}</small>
<span style="font-size: 14px; font-weight: 700;">{{ message.user.username }}</span>
<p style="font-size: 14px">{{ message.message }}</p>
</li>
</ul>
</div>
<form name="chatForm" class="form-horizontal" ng-submit="sendMessage()" novalidate>
<fieldset>
<div class="input-group" style="margin-bottom: 15px">
<input name="message" type="text" data-ng-model="message" id="message_input" class="form-control" placeholder="Message" [required="test"] ng-keypress="keypressEvent()" ng-model-options="{ debounce: 2000 }">
<span class="input-group-btn">
<button class="btn btn-default">Send</button>
</span>
</div>
<div data-ng-show="error" class="text-danger">
<strong data-ng-bind="error"></strong>
</div>
</fieldset>
</form>
</div>
<div class="col-md-2">
asd
</div>
</section>
聊天
自闭症
{{userWriting}}
-
{{message.created | timeDuration}}
{{message.user.username}
{{message.message}
发送
自闭症
我做错了什么?我该怎么做才能让它工作?
谢谢您必须为控制器提供一个名称
angular
.module('myApp', ['angularMoment'])
.controller('MyController', function(angularMoment) {
});
开发人员控制台上的输出显示了什么?您添加脚本的顺序是什么?您还需要添加moment.js-这个应该先添加到angular-moment.js.moment,然后再添加到angular-moment。控制台也不会返回任何错误,它只是表现为没有到控制器的路由。@DasBoot我想我们需要查看更多代码。我不确定您想要查看哪些特定代码。因为我在这个角度时刻所做的一切就是把它注入到一个应用程序中,而这个应用程序在没有它的情况下运行良好。让我知道你们想看什么。我把代码片段改成了我的特定代码片段,你们可以看到有一个名字。在前面的示例中,我可能遗漏了它。您可以发布一些额外的代码吗?例如,使用控制器或力矩模块的视图。