angularjs - How to Store Values from Controller into Service? -


i have ng-repeat list in partial. list(messages), want store clicked item service, dont want store one, want store many clicked.

on otherhand want able pull data , place controller have service on.

if see way improve existing code please let me know. still learning angularjs fun!

the feature similar to: http://qnimate.com/facebook-style-chat-box-popup-using-javascript-and-css/

except not know how convert method angularjs.

  1. user clicks on message
  2. message appears on taskbar
  3. user can add multiple messages taskbar

i have kind of started service:

app.factory('chatbox',['$http',function($http){    var chats; << variable hold chats array     return {       killchat:  function (userid) {        },       registerchat: function (userid) {        }   };  }]); 

and controller:

app.controller("taskbarcontroller", ['$scope', 'authdata', '$location', '$aside', 'poller',   function ($scope, authdata, $location, $aside, poller) {      $scope.openchat = function() {         // function add message service array     }      $scope.getchat = function() {         // retrieve open chats array , display on taskbar?         // possible template return data html , inject needed?     }      $scope.openaside = function(position) {       $aside.open({         placement: position,         templateurl: 'partials/sidemenu.html',         size: 'sm'         });     };      $scope.logout = function () {         authdata.get('logout').then(function (results) {             authdata.toast(results);             $location.path('login');         });     }      authdata.get('session');  }]); 


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -