Here is HTML with internal script
<html>
<body ng-controller="test">
<span> {{data.name}} </span>
<input ng-model="data.name">
<hidden id="test" ng-hide="true"></hidden>
</body>
<script>
var $scope = angular.element(document.getElementById('test')).scope();
$scope.data = {
name : test;
};
<script>
</html>
Here is Controller
app.controller('test', function($scope) {
$scope.data = {};
console.log($scope.data.name) //outputs undefined
})
I want internal script data into the controller. It prints undefined. I defined an object in the controller but updated in the internal script. If suppose I print or bind data from HTML, it does not get updated in the controller scope object. Any Solution for this?
Did you try to fetch it from the controller? Or maybe you will need a more angularjs approach. I created two examples: one for initializing the data in the controller, and one to console.log the
niceLittleValue.