0
I’m wanting to take the option chosen by the person and simply print on the screen (it’s just the basics, to then do what I really want), so I don’t know how to do it. The part of the HTML code that has {{ value }} is where I want the q to appear was selected in the box of choice.Note, I need this information to be able to use in Javascript code and not in HTML, for later power for each type of choice to do something different in JS... My code to follow:
HTML:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="java.js"></script>
</head>
<body ng-app="pag" ng-controller = "botao">
<div ng-repeat = "fig in figuras">
<select>
<option ng-model = "escolha" Ng-repeat = "x in name">{{x}}</option>
</select>
<caixa ng-repeat = "ponto in fig.pontos">
<input type = "text" ng-model="ponto.x" size = "5">
</caixa>
</div>
<div>
<button ng-click="mais()" >Adicionar mais</button>
</div>
valor: {{ valor }}
</body>
</html>
Javascript:
class Ponto {
contructor(x,y){
this.x = x;
this.y = y;
}
}
class Figura {
constructor(){
this.pontos = [];
this.pontos.push(new Ponto());
this.pontos.push(new Ponto());
}
}
var pag = angular.module('pag', [])
pag.controller('botao',function($scope){
$scope.name = ["Linha","circulo"]
$scope.figuras=[]
$scope.mais = function(){
f1 = new Figura();
$scope.figuras.push(f1);
}
$scope.pontos
})
but wouldn’t that just take op1 1?How would I pick up the result that person chose? would this.choice = "ex.choice" ?
– Gabriel Oliveira Guimarães
The result would be in the variable
escolha
of the controllerexemplo
, which, in html can be accessed byexemplo.escolha
or, using an aliasex.escolha
, edited the question, see if it became clearer– Costamilam