I
I
Ivan Damaskin2015-08-21 16:56:03
Angular
Ivan Damaskin, 2015-08-21 16:56:03

Can I use angular to assign a value to a variable in the html page and then work with it in the controller?

Hello.
The question is -
I use angulras to write the following code in html

<body>
{{numb = 10}}
</body>

Can I further use the numb variable in the controller?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Arthur, 2015-08-21
Mudrick @mudrick

Yes, you can, but it's called... shitcode. In no case should logic be moved from the controller to the template (oh, horror) - only shitcoders do this, it’s like that and nothing else.

S
Sergey, 2015-08-21
Protko @Fesor

Yes, of course, something like this:

<script>
angular
    .module('app.data')
    .value('numb', 10);
</script>

L
lega, 2015-08-21
@lega

ng-init="numb=10"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question