Change item with click

0

When you make click the focus should go to text

> var element = $window.document.getElementById('textAreaContent');
>         if(element)
>           element.focus();
> 
>     <span id="click">clickeame</span>
>     <input type="text" id="myInputId" />
    
asked by hubman 28.06.2017 в 18:09
source

2 answers

1

Good, you can do something like this:

var element = $window.document.getElementById(id);
    if(element)
      element.focus();

Functional example: link

I hope it's what you're looking for, if not, ask everything you need.

    
answered by 28.06.2017 в 18:18
0
Te dejo un ejemplo.


<!DOCTYPE html>
<html ng-app="angularjs-starter">

  <head lang="en">
    <meta charset="utf-8">
    <title>Ejemplo</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
    <link rel="stylesheet" href="style.css">
    <script>
      document.write('<base href="' + document.location + '" />');
    </script>
    <script src="app.js"></script>

  </head>

  <body ng-controller="MainCtrl">
     <h1>Hola {{name}}</h1>

    <button ng-click="myfocus()">Presioname</button>
    <input type="text" id="myinput">
  </body>

</html>
    
answered by 28.06.2017 в 18:26