get Text field value in client controller Wiget

Ujjwal1
Tera Contributor

hi all,

I have input field (text area) in Widget.

 

 

   <textarea rows="1" cols="50" ng-model="data.comment_input">

 

 

Requirement is to get input value in client Controller.

 

Below code is not working 

 

 

console.log( "input value is : " + c.data.comment_input.value);

 

 

 

Please suggest.

1 ACCEPTED SOLUTION

saurabh_dubey
Kilo Sage

Hi @Ujjwal1

 

I replicated your code in my instance

 

HTML template:

 

<div>
<!-- your widget template -->
     <textarea rows="1" cols="50" ng-model="data.comment_input">
     </textarea>
</div>

 

Client side: 

api.controller=function() {
  /* widget controller */
  var c = this;
	
	console.log( "input value is : " + c.data.comment_input);
};

 

Server side:

 

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
  data.comment_input = "Dummy Value";
})();

 

and it's working, please review based on my inputs.

 

If my solution helped you, please hit the helpful button also do accept the solution if it serves the purpose.

 

Thanks,

Saurabh Dubey.

View solution in original post

1 REPLY 1

saurabh_dubey
Kilo Sage

Hi @Ujjwal1

 

I replicated your code in my instance

 

HTML template:

 

<div>
<!-- your widget template -->
     <textarea rows="1" cols="50" ng-model="data.comment_input">
     </textarea>
</div>

 

Client side: 

api.controller=function() {
  /* widget controller */
  var c = this;
	
	console.log( "input value is : " + c.data.comment_input);
};

 

Server side:

 

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
  data.comment_input = "Dummy Value";
})();

 

and it's working, please review based on my inputs.

 

If my solution helped you, please hit the helpful button also do accept the solution if it serves the purpose.

 

Thanks,

Saurabh Dubey.