0

I am trying to learn angularjs.

I have the following controller,

   skillPopulator.controller('skillsetController', function(){
         this.skillType = language; //value to be changed
    });

language and database are jsons in custom.js within the wrapper where controller is present like

var language = {         
            name: 'Java, Javascript, HTML5, CSS3'
        }
var database = {         
            name: 'MySQL, Oracle, PostGres'
        }

I would like to change the value of skillType to database upon the event

$("#db-skill").hover();

1) If I do so, will the change get reflected on my {{skill.skillType.name}} without a refresh?

2) How would I do it?

2 Answers 2

1

if you want to use your variables at html side you should add them to $scope, so your basic jsons in controller like this has no meaning at html side, that is why you see no changes when you over your html item...

change your jsons to this...

$scope.language = {         
            name: 'Java, Javascript, HTML5, CSS3'
        }
$scope.database = {         
            name: 'MySQL, Oracle, PostGres'
        }

and here is a working PLUNKER...

Sign up to request clarification or add additional context in comments.

Comments

0

You could use ng-mouseover See docs: https://docs.angularjs.org/api/ng/directive/ngMouseover

Instead of using this

$("#db-skill").hover();

use this:

<ANY id="db-skill" ng-mouseover="skillType = database"></ANY>

2 Comments

When I do that, it removes the current value. But it does not update it with the 'database.name' value. As if it is not able to find the json variable 'database'
Can you provide a plunkr or fiddle?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.