How to call function from server to html ?

Carol11
Kilo Expert

When the button is clicked, i want the value to change from 0 to 1. I can do this on client script, but its not working on server script.

HTML :
<button ng-click="c.data.getcc()">
search
</button>
<span>{{c.data.cc}}</span>

SERVER SCRIPT :

data.cc = 0;

function getcc(){

data.cc++;


}

 

1 ACCEPTED SOLUTION

Carol11
Kilo Expert

Fixed it, but it only counts to 1 , once.

client:

function()
{
var c = this;

c.open = function()
{

c.server.update();
}
}

server:

(function()
{
data.count=0;

if(input)
{
data.count++;
}

})();

 

i will find out why it doesnt count more than once. thank you for the help 🙂 

View solution in original post

4 REPLIES 4

Priyanka136
Mega Guru

Hi Carol,

Try this code :-

HTML:-

<div>
  
<button class = "btn btn-success" ng-click="c.open()">Search</button>
 
  {{data.count}}
    
</div>


Client Script:-

function() 
{
  var c = this;
	
	c.open = function()
	{
		c.data.OpenBtn = "true";
		c.server.update();
	}
}


Server Script:-

(function()
 {
	data.count=0;
	
	if(input.OpenBtn == "true")
	{	
		data.count++;
	}
	
})();


find_real_file.png

Let me know if you have any questions.

Please mark it Correct or Helpful, if it works based on impact....!!!!

Warm Regards,

Priyanka

find_real_file.png

www.dxsherpa.com

 

Carol11
Kilo Expert

Hi, i get to 1 but it doesnt continue. and i have errors.

find_real_file.png

 

 

 

Carol11
Kilo Expert

Fixed it, but it only counts to 1 , once.

client:

function()
{
var c = this;

c.open = function()
{

c.server.update();
}
}

server:

(function()
{
data.count=0;

if(input)
{
data.count++;
}

})();

 

i will find out why it doesnt count more than once. thank you for the help 🙂 

Trying My Best:

Because as per the execution order server loads first,

and

1  it shows the value 1 after data.count++ .

2  then again you try to click on button again it loaded using c.server.update() so you are getting same value again instead of increment.

 

and it is not showing incremented value.

 

 

Regards,

Varsha.