Angularjs ui日历工具提示功能不工作

Angularjs ui日历工具提示功能不工作,angularjs,fullcalendar,ui-calendar,Angularjs,Fullcalendar,Ui Calendar,calendar可显示日历和一组事件(截至目前,事件已硬编码)。但当我将鼠标悬停在事件上时,工具提示不会显示。我在网上搜索了许多答案,但没有一个对我有效,除工具提示外的所有其他内容都有效。请帮助。以下是我的js代码 var-app=angular.module('myApp',['ui.calendar','ui.router']); app.controller('myNgController',['$scope','$http','uiCalendarConfig',函数($scope,$

calendar可显示日历和一组事件(截至目前,事件已硬编码)。但当我将鼠标悬停在事件上时,工具提示不会显示。我在网上搜索了许多答案,但没有一个对我有效,除工具提示外的所有其他内容都有效。请帮助。以下是我的js代码

var-app=angular.module('myApp',['ui.calendar','ui.router']);
app.controller('myNgController',['$scope','$http','uiCalendarConfig',函数($scope,$http,uiCalendarConfig){
$scope.SelectedEvent=null;
var isFirstTime=true;
$scope.events=[];
$scope.eventSources=[$scope.events];
$scope.events.push({
标题:“事件”,
描述:“jahsojoaisjjoijaso”,
开始日期:新日期(“2017-05-03”),
结束:新日期(“2017-05-03”),
全天:错,
棒:假
});
$scope.uiConfig={
日历:{
身高:450,
可编辑:false,
displayEventTime:false,
标题:{
左:“月基本周基本日代理周代理日”,
中心:'标题',
右图:“今天上一个,下一个”
},
事件单击:函数(事件){
$scope.SelectedEvent=事件;
},
eventAfterAllRender:function(){
如果($scope.events.length>0&&isFirstTime){
//焦点第一事件
uiCalendarConfig.calendars.myCalendar.fullCalendar('gotoDate',$scope.events[0].start);
isFirstTime=false;
}
}
}
};
$scope.eventRender=函数(事件、元素、视图){
元素attr({'tooltip':event.title,
“工具提示附加到正文”:true});
$compile(元素)($scope);
};

}]);必须在日历配置定义()中设置该函数:

不要忘记将
$compile
注入控制器:

app.controller('myNgController', ['$scope', '$http', '$compile', 'uiCalendarConfig', function($scope, $http, $compile, uiCalendarConfig) {
app.controller('myNgController', ['$scope', '$timeout', '$http', '$compile', 'uiCalendarConfig', function($scope, $timeout, $http, $compile, uiCalendarConfig) {
至于我们在评论中的讨论,您将看到“TypeError:无法读取未定义”错误的属性“fullCalendar”。试试下面的方法

$timeout
注入控制器:

app.controller('myNgController', ['$scope', '$http', '$compile', 'uiCalendarConfig', function($scope, $http, $compile, uiCalendarConfig) {
app.controller('myNgController', ['$scope', '$timeout', '$http', '$compile', 'uiCalendarConfig', function($scope, $timeout, $http, $compile, uiCalendarConfig) {
并用
$timeout
将这一行括起来:

uiCalendarConfig.calendars.myCalendar.fullCalendar('gotoDate', $scope.events[0].start);
因此,最终结果将是:

$timeout(function() {
    uiCalendarConfig.calendars.myCalendar.fullCalendar('gotoDate', $scope.events[0].start);
});
这将确保仅在视图完成渲染后才调用
fullCalendar

至于甜点,请看一下如何设置工具提示:

element.attr({
    'tooltip': event.title,
    'tooltip-append-to-body': true
});
请注意,它添加了
tooltip=“
tooltip append to body=“true
,但为了显示工具提示,您需要设置
title
属性。将其更改为:

element.attr({
    'title': event.title,
    'tooltip-append-to-body': true
});

我猜您认为它是Bootstrap.UI tooltip(),因此在这种情况下,您需要进行必要的更改以正确实现它。但是使用
title
将确保当鼠标悬停在事件上方时,浏览器将向您显示默认工具提示(使用本机HTML“title”属性)。

我已包含所有依赖项,并再次更新了问题。我想我已将myCalendar部分添加为well@vikk见我的最新答案,让我知道它是否有帮助我们的意思是说只添加$timeout(function(){uiCalendarConfig.calendars.myCalendar.fullCalendar('gotoDate',$scope.events[0].start);});关闭ui.config之后,对吗?这显示了类型错误twice@vikk是,如更新的答案中所述。我有一个类似的问题,所以我查看了我的代码,发现我通过使用
$timeout
包装它来解决它,所以请确保您正在包装该行