twinssbc / Ionic-Calendar

A calendar directive for Ionic framework
http://twinssbc.github.io/Ionic-Calendar/demo
MIT License
159 stars 73 forks source link

month detail view customization. ng-click event not working #159

Open raheelshan opened 7 years ago

raheelshan commented 7 years ago

Hi, i am customizing view like this

$scope.monthviewEventDetailTemplateUrl = 'templates/event-details.html';

Next i am customizing view by adding edit and delete controls when user views the details of event.

<tr ng-repeat="event in selectedDate.events">
    <td class="event-detail">
        {{::event.title}}
    </td>
    <td><i class="icon ion-ios-pencil-outline" ng-click="alert('hello')">Edit Event</i></td>
    <td><i class="icon ion-ios-trash-outline" ng-click="DeleteEvent(event)">Delete Event</i></td>
</tr>

Neither DeleteEvent nor alert is working. What can i do now?

twinssbc commented 7 years ago

@raheelshan Yes, it will try to look for method bind to the current scope, which is the internal scope in the calendar. So it can't call a method defined in your scope. As a workaround, you could add some method to your event object.

raheelshan commented 7 years ago

i tried adding methods but it still fails.

twinssbc commented 7 years ago

@raheelshan Could you show me how do you add the method, and what's the error message?

raheelshan commented 7 years ago

For testing i added these into directive scope to see if it works

eventDeleted: '&',
eventEdited: '&',

Then in

event-deleted="onEventDeleted(event)" event-edited="onEventEdited(event)" 

And added these two methods in controller

$scope.onEventEdited = function (event) {
    console.log('Event selected:' + event.startTime + '-' + event.endTime + ',' + event.title);
};

$scope.onEventDeleted = function (event) {
    console.log('Event selected:' + event.startTime + '-' + event.endTime + ',' + event.title);
};

It doesn't seem to work as it works for event-selected. The alternate way i found to work is to create a directive and achieved this.

twinssbc commented 7 years ago

@raheelshan Do you mean you were trying to modify the source code but it didn't work?