{"id":2060,"date":"2013-11-15T21:01:25","date_gmt":"2013-11-15T18:01:25","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2060"},"modified":"2026-03-23T15:54:27","modified_gmt":"2026-03-23T12:54:27","slug":"creating-event-calendar-with-dhtmlxscheduler-and-angularjs","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/creating-event-calendar-with-dhtmlxscheduler-and-angularjs\/","title":{"rendered":"Creating Event Calendar with dhtmlxScheduler and AngularJS"},"content":{"rendered":"<p><a href=\"https:\/\/angularjs.org\/\">AngularJS<\/a> is a modern JavaScript framework that allows creating rich client-side apps in a fast and productive way. It goes without saying that AngularJS is convenient and powerful in working with HTML. However, it doesn&#8217;t have ready to use complex UI components yet. In this article we&#8217;ll try to partially eliminate this drawback by showing how to add support of <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/\">DHTMLX Scheduler<\/a> for an AngularJS app.<\/p>\n<p><strong><a href=\"\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/download.shtml\">Download dhtmlxScheduler to add a powerful scheduling calendar to your app<\/a><\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2070\" title=\"AngularJs Event Calendar with dhtmlxScheduler\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/scheduler-angularjs.jpg\" alt=\"Angular Js Event Calendar with dhtmlxScheduler\" width=\"600\" height=\"338\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/scheduler-angularjs.jpg 600w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/scheduler-angularjs-300x169.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br \/>\nYou can <a href=\"https:\/\/github.com\/DHTMLX\/angular-suite-demo\">check the online demo<\/a> of a ready app or just grab the sources of the app from <a href=\"https:\/\/github.com\/DHTMLX\/angularjs-scheduler-demo\">GitHub<\/a>.<\/p>\n<h3>Adding dhxScheduler Directive<\/h3>\n<p>In order to build a custom HTML component in AngularJS we need to create a new directive. So let&#8217;s start integrating the Scheduler from writing a directive for it. For this purpose we need to create a .js file with the following content:<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">app.<span class=\"me1\">directive<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'dhxScheduler'<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> <span class=\"br0\">&#123;<\/span><br \/>\nrestrict<span class=\"sy0\">:<\/span> <span class=\"st0\">'A'<\/span><span class=\"sy0\">,<\/span><br \/>\nscope<span class=\"sy0\">:<\/span> <span class=\"kw2\">false<\/span><span class=\"sy0\">,<\/span><br \/>\ntransclude<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\ntemplate<span class=\"sy0\">:<\/span><span class=\"st0\">'<br \/>\n&lt;div class=&quot;dhx_cal_navline&quot;&gt;&lt;\/div&gt;<br \/>\n&lt;div class=&quot;dhx_cal_header&quot;&gt;&lt;\/div&gt;<br \/>\n&lt;div class=&quot;dhx_cal_data&quot;&gt;&lt;\/div&gt;<br \/>\n'<\/span><span class=\"sy0\">,<\/span><br \/>\nlink<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>$scope<span class=\"sy0\">,<\/span> $element<span class=\"sy0\">,<\/span> $attrs<span class=\"sy0\">,<\/span> $controller<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"co1\">\/\/adjust size of a scheduler<\/span><br \/>\n$scope.$watch<span class=\"br0\">&#40;<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> $element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">offsetWidth<\/span> <span class=\"sy0\">+<\/span> <span class=\"st0\">&quot;.&quot;<\/span> <span class=\"sy0\">+<\/span> $element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">offsetHeight<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\nscheduler.<span class=\"me1\">setCurrentView<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"co1\">\/\/styling for dhtmlx scheduler<\/span><br \/>\n$element.<span class=\"me1\">addClass<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;dhx_cal_container&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"co1\">\/\/init scheduler<\/span><br \/>\nscheduler.<span class=\"me1\">init<\/span><span class=\"br0\">&#40;<\/span>$element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;month&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>The above code may look a bit complicated, but the things the code produces are rather simple:<\/p>\n<ul>\n<li>the code defines a new directive which can be used as a custom attribute<\/li>\n<li>when the new directive (<em>dhxScheduler<\/em>) is initialized, it will create the dhtmlxScheduler object with the default settings<\/li>\n<li>the <em>watcher<\/em> function will be constantly checking the size of scheduler&#8217;s container and will resize the component when the size of HTML container changes.<\/li>\n<\/ul>\n<p><!--more--><br \/>\nFor creating an instance of dhtmlxScheduler on a page it&#8217;s actually enough to write the above code and place the directive somewhere on the page. If we want to create a simple app with a scheduler inside, the HTML code structure shown below is needed:<\/p>\n<div class=\"codecolorer-container html4strict default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"html4strict codecolorer\"><span class=\"sc2\">&lt;!doctype html&gt;<\/span><br \/>\n<br \/>\nAngular Calendar demo<br \/>\n<br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">script<\/span> <span class=\"kw3\">src<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;https:\/\/cdn.dhtmlx.com\/scheduler\/edge\/dhtmlxscheduler.js&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">script<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">script<\/span> <span class=\"kw3\">src<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;https:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.6.7\/angular.min.js&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">script<\/span>&gt;<\/span><br \/>\n<br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">script<\/span> <span class=\"kw3\">src<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;js\/app.js&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">script<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">style<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;height: 350px; width: 600px;&quot;<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_prev_button&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_next_button&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_today_button&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_date&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_tab&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_tab&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span> <span class=\"kw3\">class<\/span><span class=\"sy0\">=<\/span><span class=\"st0\">&quot;dhx_cal_tab&quot;<\/span>&gt;&lt;<span class=\"sy0\">\/<\/span><span class=\"kw2\">div<\/span>&gt;<\/span><br \/>\n<span class=\"sc2\">&lt;<span class=\"kw2\">div<\/span>&gt;<\/span><\/div><\/div>\n<p>As you can see, we&#8217;ve included the .js and .css files of both the AngularJS framework and the dhtmlxScheduler component. Our newly created <em>dxhScheduler<\/em> directive is used in the code of the page. The <em>dhx-scheduler<\/em> attribute is used to trigger the directive and to initialize the scheduler component. The HTML tags inside of <em>dhx-scheduler<\/em> div container are necessary to define the buttons on the top bar of the scheduler.<\/p>\n<p>When you open a page with the described HTML code in a browser, you will see an appointment calendar component ready to be used:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2067\" title=\"dhtmlxScheduler - Using with AngularJS\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/calendar-angularjs-1.jpg\" alt=\"dhtmlxScheduler - Using with AngularJS\" width=\"600\" height=\"350\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/calendar-angularjs-1.jpg 600w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/calendar-angularjs-1-300x175.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<h3>Linking to the Scope<\/h3>\n<p>For now our AngularJS calendar just renders itself, which is good but not quite useful yet. Let&#8217;s link the scheduler&#8217;s state and content to the scope in order to expand the app&#8217;s functionality. For this purpose we need to extend the link method of the directive as follows:<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">link<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>$scope<span class=\"sy0\">,<\/span> $element<span class=\"sy0\">,<\/span> $attrs<span class=\"sy0\">,<\/span> $controller<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"co1\">\/\/default state of the scheduler<\/span><br \/>\n<span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span><span class=\"sy0\">!<\/span>$scope.<span class=\"me1\">scheduler<\/span><span class=\"br0\">&#41;<\/span><br \/>\n$scope.<span class=\"me1\">scheduler<\/span> <span class=\"sy0\">=<\/span> <span class=\"br0\">&#123;<\/span><span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n$scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">mode<\/span> <span class=\"sy0\">=<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">mode<\/span> <span class=\"sy0\">||<\/span> <span class=\"st0\">&quot;month&quot;<\/span><span class=\"sy0\">;<\/span><br \/>\n$scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">date<\/span> <span class=\"sy0\">=<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">date<\/span> <span class=\"sy0\">||<\/span> <span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/watch data collection, reload on changes<\/span><br \/>\n$scope.$watch<span class=\"br0\">&#40;<\/span>$attrs.<span class=\"me1\">data<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>collection<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\nscheduler.<span class=\"me1\">clearAll<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\nscheduler.<span class=\"me1\">parse<\/span><span class=\"br0\">&#40;<\/span>collection<span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;json&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw2\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/watch mode and date<\/span><br \/>\n$scope.$watch<span class=\"br0\">&#40;<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">mode<\/span> <span class=\"sy0\">+<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">date<\/span>.<span class=\"me1\">toString<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>nv<span class=\"sy0\">,<\/span> ov<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">var<\/span> mode <span class=\"sy0\">=<\/span> scheduler.<span class=\"me1\">getState<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>nv.<span class=\"me1\">date<\/span> <span class=\"sy0\">!=<\/span> mode.<span class=\"me1\">date<\/span> <span class=\"sy0\">||<\/span> nv.<span class=\"me1\">mode<\/span> <span class=\"sy0\">!=<\/span> mode.<span class=\"me1\">mode<\/span><span class=\"br0\">&#41;<\/span><br \/>\nscheduler.<span class=\"me1\">setCurrentView<\/span><span class=\"br0\">&#40;<\/span>$scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">date<\/span><span class=\"sy0\">,<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">mode<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw2\">true<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/size of scheduler<\/span><br \/>\n$scope.$watch<span class=\"br0\">&#40;<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> $element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">offsetWidth<\/span> <span class=\"sy0\">+<\/span> <span class=\"st0\">&quot;.&quot;<\/span> <span class=\"sy0\">+<\/span> $element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">offsetHeight<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\nscheduler.<span class=\"me1\">setCurrentView<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/styling for dhtmlx scheduler<\/span><br \/>\n$element.<span class=\"me1\">addClass<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;dhx_cal_container&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"co1\">\/\/init scheduler<\/span><br \/>\nscheduler.<span class=\"me1\">init<\/span><span class=\"br0\">&#40;<\/span>$element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">date<\/span><span class=\"sy0\">,<\/span> $scope.<span class=\"me1\">scheduler<\/span>.<span class=\"me1\">mode<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>Let&#8217;s see what was added. The top block checks if there are settings for the scheduler in the scope. If there are no such settings, they will be created with default values.<\/p>\n<p>After the top block, two new watch instructions follow. The first instruction will monitor the state of data collection and reload the scheduler with new data when the collection is changed. The second instruction will change the scheduler&#8217;s settings (mode and date) when the related parameters are changed in the scope.<\/p>\n<p>Finally, we have slightly adjusted the <em>scheduler.init<\/em> command. Now it uses values from the scope as initial view and date values.<\/p>\n<p>After applying all these changes we can do the following:<\/p>\n<ul>\n<li>We can place custom buttons on the page. Clicking the first button will change the displayed date and clicking the second button will switch the mode of events view in the calendar:\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"sy0\">&lt;<\/span>button<span class=\"sy0\">&gt;<\/span>Week<span class=\"sy0\">&lt;\/<\/span>button<span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;<\/span>button<span class=\"sy0\">&gt;<\/span>Week<span class=\"sy0\">&lt;\/<\/span>button<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<\/li>\n<li>We can load data from the scope to the scheduler:\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">app.<span class=\"me1\">controller<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'MainSchedulerCtrl'<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>$scope<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n$scope.<span class=\"me1\">events<\/span> <span class=\"sy0\">=<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n<span class=\"br0\">&#123;<\/span> id<span class=\"sy0\">:<\/span><span class=\"nu0\">1<\/span><span class=\"sy0\">,<\/span> text<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;Task A-12458&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\nstart_date<span class=\"sy0\">:<\/span> <span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2018<\/span><span class=\"sy0\">,<\/span> 09<span class=\"sy0\">,<\/span> <span class=\"nu0\">30<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">9<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span><br \/>\nend_date<span class=\"sy0\">:<\/span> <span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2018<\/span><span class=\"sy0\">,<\/span> 09<span class=\"sy0\">,<\/span> <span class=\"nu0\">30<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">16<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n<span class=\"br0\">&#123;<\/span> id<span class=\"sy0\">:<\/span><span class=\"nu0\">2<\/span><span class=\"sy0\">,<\/span> text<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;Task A-83473&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\nstart_date<span class=\"sy0\">:<\/span> <span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2018<\/span><span class=\"sy0\">,<\/span> 09<span class=\"sy0\">,<\/span> <span class=\"nu0\">28<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">9<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">,<\/span><br \/>\nend_date<span class=\"sy0\">:<\/span> <span class=\"kw1\">new<\/span> <span class=\"kw4\">Date<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2018<\/span><span class=\"sy0\">,<\/span> 09<span class=\"sy0\">,<\/span> <span class=\"nu0\">30<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">16<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#93;<\/span><span class=\"sy0\">;<\/span><span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<\/li>\n<li>We can use some input on the page to filter the scheduler:\n<div style=\"height: 350px; width: 600px;\"><\/div>\n<\/li>\n<\/ul>\n<p>Thus we have a scheduler populated with data. The scheduler has the functions of date and mode changing, and data filtering. Next we can customize the appearance of events in the scheduler.<\/p>\n<h3>The Look of Events<\/h3>\n<p>Well, we can now define the content and appearance of event bars in the calendar. dhtmlxScheduler provides JavaScript API for templating and we can take the advantage of this API to specify the look of events in our calendar. The code below will define one more directive which can be used to define the scheduler&#8217;s templates:<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">app.<span class=\"me1\">directive<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'dhxTemplate'<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#91;<\/span><span class=\"st0\">'$interpolate'<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>$interpolate<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> <span class=\"br0\">&#123;<\/span><br \/>\nrestrict<span class=\"sy0\">:<\/span> <span class=\"st0\">'AE'<\/span><span class=\"sy0\">,<\/span><br \/>\nterminal<span class=\"sy0\">:<\/span><span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\n<br \/>\nlink<span class=\"sy0\">:<\/span><span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>$scope<span class=\"sy0\">,<\/span> $element<span class=\"sy0\">,<\/span> $attrs<span class=\"sy0\">,<\/span> $controller<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n$element<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>.<span class=\"me1\">style<\/span>.<span class=\"me1\">display<\/span> <span class=\"sy0\">=<\/span> <span class=\"st0\">'none'<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">var<\/span> htmlTemplate <span class=\"sy0\">=<\/span> $interpolate<span class=\"br0\">&#40;<\/span>$element.<span class=\"me1\">html<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\nscheduler.<span class=\"me1\">templates<\/span><span class=\"br0\">&#91;<\/span>$attrs.<span class=\"me1\">dhxTemplate<\/span><span class=\"br0\">&#93;<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>start<span class=\"sy0\">,<\/span> end<span class=\"sy0\">,<\/span> event<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> htmlTemplate<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span>event<span class=\"sy0\">:<\/span> event<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n<br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>This code defines the <em>dhxTemplate<\/em> directive. This directive can be used both as an attribute or as a custom tag. The content of the directive will be converted to JavaScript function and used as a template of the scheduler. To specify the template for the scheduler, you can use the native AngularJS templates. This syntax implies the use of the <em>{{event.property}}<\/em> expressions as placeholders in the template&#8217;s text.<\/p>\n<p>For example, we can add the following code on the page:<\/p>\n<p>&nbsp;<\/p>\n<div><strong>#{{event.id}}<\/strong>: {{event.text | uppercase}}<\/div>\n<p>&nbsp;<\/p>\n<p>The above code will produce the result as follows:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2068\" title=\"dhtmlxScheduler and AngularJS - Custom Template\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/event-calendar-angularjs-2.png\" alt=\"dhtmlxScheduler and AngularJS - Custom Template\" width=\"600\" height=\"349\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/event-calendar-angularjs-2.png 600w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/event-calendar-angularjs-2-300x174.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><br \/>\nThe <em>dhx-template<\/em> attribute&#8217;s name (&#8220;<em>event_bar_text<\/em>&#8221; ) is the name of scheduler&#8217;s template which needs to be defined. Check the full list of templates in the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__refs__scheduler.html#templates\">documentation<\/a>.<\/p>\n<p>Take into account the following points:<\/p>\n<ul>\n<li>You need to use the format of the type <em>{{event.some}}<\/em> to define the template. Instead of &#8220;some&#8221; place the necessary property of event object. &#8220;event.&#8221; in our example is a fixed part that is used only by the scheduler to define the event&#8217;s property. It is not related to the current scope.<\/li>\n<li>You can&#8217;t use the scope&#8217;s variables inside of the template.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>Summing Up<\/h3>\n<p>So although there are no complex UI components in Angular JS, we can add such a component with the help of some additional code. Thus, by using the two directives defined above (<em>dhxScheduler<\/em> and <em>dhxTemplate<\/em>) you can easily add a rich-featured calendar on the page and customize its appearance.<\/p>\n<p><a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/download.shtml\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3704\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/download-scheduler-banner.png\" alt=\"download scheduler\" width=\"900\" height=\"300\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/download-scheduler-banner.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/download-scheduler-banner-300x100.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/11\/download-scheduler-banner-768x256.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<p>The above described functionality of the <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/\" target=\"_blank\">scheduler component<\/a> is just a tip of the iceberg. dhtmlxScheduler has a rich API and lots of properties and events. It makes no sense to wrap all of them into AngularJS directives, as you can easily make any necessary calls from Angular controller&#8217;s code (check the details of the dhtmlxScheduler API in the <a href=\"https:\/\/docs.dhtmlx.com\/scheduler\/api__refs__scheduler.html\">documentation<\/a>).<\/p>\n<p>The simplicity of integration shows the flexibility of both AngularJS and dhtmlxScheduler. While both of them are independent solutions, with a bit of glue code they work together in a neat way. By using the above code you can get a Google-like appointment calendar for your AngularJS web app.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AngularJS is a modern JavaScript framework that allows creating rich client-side apps in a fast and productive way. It goes without saying that AngularJS is convenient and powerful in &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3799,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,1,38],"tags":[33,40,14,15],"class_list":["post-2060","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-uncategorized","category-visible","tag-all-posts","tag-angularjs","tag-tips","tag-dhtmlxscheduler"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=2060"}],"version-history":[{"count":10,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2060\/revisions"}],"predecessor-version":[{"id":15303,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2060\/revisions\/15303"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3799"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}