Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Why I can't change value using function? AngularJS

html:

<div ng-controler='TestCtrl' id='TestCtrl'>
    <h1>Test: {{test.name}}</h1>

    <div ng-hide='showTest'>
        <div class='content'>
            <p>First name: <input ng-model='firstName'></p>
            <p>Last name: <input ng-model='lastName'></p>
        </div>
        <div jq-ui-button ng-click='doSth()'>
            Do something
        </div>
    </div>
</div>

JS:

app.controller('TestCtrl', function ($scope) {
    $scope.showTest = false;
    $scope.test = {name:'Test name'};

    $scope.doSth = function() {
        $scope.showTest = true;
    }
}

It does not work. But when I write:

<div jq-ui-button ng-click='showTest = true'>

It works.

Where is the problem?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You must write ng-controller not ng-controler. That's why your code is not used. First line in your HTML.

share|improve this answer
    
Thank you. I searched the error hour. –  Niezbor Jan 12 at 21:11
    
@Niezbor i know these situations too:) –  michael Jan 12 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.