AngularJS and Blocshop's Sockets for Cordova problem

So, this is my first time with Ionic and i need to develop an app which connects to a TCP Server ang grab it’s response then parse the response into some info.

I’m able to connect to the server and grab the response using Socket For Cordova but only if the code is inside the,everything works fine but i need to move the socket into a controller and this is where things gets messy. The same working code i’ve used in the function doesn’t work in the controller function, it doesn’t connect to the server and also, every code after the socket initialization stops working.

Is there a way to fix this or is there any alternative for Sockets for Cordova that allows me to connect to a TCP Server?