New to Ionic and Angular. Help with calendar


#1

Calendar.js

angular.module("starter.directives", []);
angular.module('starter.directives').directive("calendar", function(){
    return {
        restrict: "E",
        templateUrl: "templates/calendar.html",
        scope: { selected: "=" },
        link: function(scope) {
            scope.selected = _removeTime(scope.selected || moment());
            scope.month = scope.selected.clone();
            var start = scope.selected.clone();
            start.date(1);
            _removeTime(start.day(0));
            _buildMonth(scope, start, scope.month);

            scope.select = function(day) { scope.selected = day.date; };
            scope.next = function() {
                var next = scope.month.clone();
                _removeTime(next.month(next.month()+1)).date(1));
                scope.month.month(scope.month.month()+1);
                _buildMonth(scope, next, scope.month);
            };

            scope.previous = function()
            {
                var previous = scope.month.clone();
                _removeTime(previous.month(previous.month()-1).date(1));
                scope.month.month(scope.month.month()-1);
                _buildMonth(scope, previous, scope.month);
            };
        }
    };
    function _removeTime(date){ 
        return date.hour(0).minute(0).second(0).millisecond(0);
        //return date.day(0).hour(0).minute(0).second(0).millisecond(0); }
    function _buildMonth(scope, start, month) {
        scope.weeks = [];
        var done = false, date = start.clone(), monthIndex = date.month(), count = 0;
        while (!done) {
            scope.weeks.push({ days: _buildWeek(date.clone(), month) });
            date.add(1, "w");
            done = count++ > 2 && monthIndex !== date.month();
            monthIndex = date.month();
        }
    }
    function _buildWeek(date, month) {
        var days = [];
        for (var i = 0; i < 7; i++) {
            days.push({
                name: date.format("dd").substring(0, 1),
                number: date.date(),
                isCurrentMonth: date.month() === month.month(),
                isToday: date.isSame(new Date(), "day"),
                date: date
            });
            date = date.clone();
            date.add(1, "d");
        }
        return days;
    }
});

tab-dash.html

...
 <div class="item item-body">
      <calendar selected="day"></calendar>
  </div>
...

I have included calendar.js in my index.html template and same with moments.js and underscore.js

Nothing comes up where i thought i should see a calendar…

Here is the error from devTools

[Error] SyntaxError: Unexpected token ')' http://0.0.0.0:8101/js/calendar.js Line: 18
	(anonymous function) (0.0.0.0, line 28)
	onerror (0.0.0.0, line 12)
[Error] SyntaxError: Unexpected token ')'
	(anonymous function) (calendar.js, line 18)

#2

I figured it out I was missing a brace } on line 32.