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.
- user clicks on message
- message appears on taskbar
- 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
Post a Comment