I'm relatively new to angularJS.
I've a set of objects in an array. I'm creating dynamic content with these 
objects. Now, when I click on "Add to outlook" button in each of the divs, 
I need to add them to outlook.

How can I use 'addtocalendar 
<https://github.com/jshor/angular-addtocalendar>' over here?

Here's the code, I've written so far -
<html>
  <head>
    <style>
  .event {
    height: 150px;
    width: 250px;
    border: 1px solid lightgrey;
    background-color: skyblue;
    margin: 10px;
  }
 </style>
 <script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js";
></script>
  </head>
  <body>
 <div ng-app="myApp" ng-controller="myCtrl">
  <div ng-repeat="eventObj in card" class="event">
  Subject: <span>{{eventObj.Name}}</span>
  <br /><br /> 
  Venue:<span>{{eventObj.Venue}}</span>
  <br /><br /> 
  Date:<span>{{eventObj.StartDate | date:'fullDate'}}</span>
  <br /><br />
  <button ng-click="add(eventObj.EventID)">Add to Outlook</button>
  </div>
 </div>
 <script>
  angular.module('myApp', []).controller('myCtrl', function($scope){
    $scope.card = [{
    Name: "New Year Celebration",
    Description: "",
    Venue: "",
    StartDate: "Fri Dec 29 2017 23:30:00 GMT+0530",
    EndDate: "Sat Dec 30 2017 00:30:00 GMT+0530",
    EventID: "1"
  }, {
    Name: "25th Anniversary Celebration",
    Description: "25th Anniversary Celebration of organization",
    Venue: "Auditorium",
    StartDate: "Wed May 31 2017 17:30:00 GMT+0530",
    EndDate: "Wed May 31 2017 20:30:00 GMT+0530",
    EventID: "2"
  }, {
    Name: "Annual Day",
    Description: "",
    Venue: "",
    StartDate: "Fri Oct 13 2017 14:30:00 GMT+0530",
    EndDate: "Fri Oct 13 2017 17:30:00 GMT+0530",
    EventID: "3"
  }];


  $scope.add = function(eventObj) {
    $scope.eventID= this.eventObj.EventID;
    $scope.startDate= this.eventObj.StartDate;
 $scope.endDate= this.eventObj.EndDate;
 $scope.venue= this.eventObj.Venue;
 $scope.subject= this.eventObj.Name;
 $scope.result= this.eventObj.Description;
    //console.log(this);
 $scope.icsMSG = 
"BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nUID:[email protected]\nDTSTAMP:"+ 
$scope.startDate +"\nATTENDEE;CN=My Self 
;RSVP=TRUE:MAILTO:[email protected]\nORGANIZER;CN=Me:MAILTO:[email protected]\nDTSTART:"
 
+ $scope.startDate +"\nDTEND:" + $scope.endDate +"\nLOCATION:" + $scope.venue 
+ "\nSUMMARY:"+ $scope.subject + "\nEND:VEVENT\nEND:VCALENDAR";
 window.open( "data:text/calendar;charset=utf8," + escape($scope.icsMSG));
  };
 </script>
  </body>  
</html>


-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to