在我的package.json
文件中,我将bower列为依赖项.运行后npm install
,bower在本地安装.当我在本地安装它后尝试运行bower时出现错误
"bower"不被视为内部或外部命令
似乎解决这个问题的唯一方法是全球安装bower.我为什么要这样做?如果我的项目包含凉亭的本地副本,为什么节点不会使用它?
我试图访问ui-calendar中的fullcalendar对象.文档说我需要做的就是给calendar属性一个名字:
<div ui-calendar="calendarOptions" ng-model="eventSources" calendar="myCalendar">
Run Code Online (Sandbox Code Playgroud)
然后,您应该能够访问日历:
uiCalendarConfig.calendars.myCalendar
Run Code Online (Sandbox Code Playgroud)
这不适合我.我回来的对象总是空的.我试图最终做的是以编程方式切换视图.如果我自己只使用fullcalendar,我就是这样做的:
.fullCalendar( 'changeView', viewName )
Run Code Online (Sandbox Code Playgroud)
如何使用ui-calendar指令执行此操作?
编辑*我的实际配置对象:
$scope.uiConfig = {
calendar:{
height: 700,
editable: true,
timezone:'America/Los Angeles',
ignoreTimezone:false,
header:{
left: 'month basicWeek basicDay agendaWeek agendaDay',
center: 'title',
right: 'today prev,next'
},
eventDrop: $scope.onEventDrop,
eventClick : $scope.onEventClick,
eventResize : $scope.onEventResize,
viewDisplay : $scope.onViewDisplay
}
};
Run Code Online (Sandbox Code Playgroud)
我的实际日历指令调用:
<div ui-calendar="uiConfig.calendar" ng-model="events" calendar="myCalendar"></div>
Run Code Online (Sandbox Code Playgroud)
我的控制器:
app.controller('CalendarCtrl', function($scope, $http, $rootScope, uiCalendarConfig){
// bunch of methods plus $scope.uiConfig as shown above
// console.log(uiCalendarConfig) outputs {}
});
Run Code Online (Sandbox Code Playgroud) 使用Javascript:
$('#pagination-demo').twbsPagination({
totalPages: 35,
visiblePages: 7,
onPageClick: function (event, page) {
console.log('Why does this run on load?');
}
});
Run Code Online (Sandbox Code Playgroud)
标记:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://esimakin.github.io/twbs-pagination/js/jquery.twbsPagination.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<ul id="pagination-demo" class="pagination-sm"></ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JS Bin在这里:http://jsbin.com/potekina/1/edit
在onPageClick回调中,我登录到控制台"为什么这会在加载时运行?" 我不明白为什么代码在加载时运行,如果它只在链接被点击时发生.为什么它在负载下运行?
angularjs ×1
bower ×1
callback ×1
fullcalendar ×1
javascript ×1
jquery ×1
node.js ×1
npm ×1
windows-7 ×1