I want to initialize a Angular model with a JSON object which is embedded in a HTML page. Example:
<html>
<body>
<script type="text/javascript" charset="utf-8">
var tags = [{"name": "some json"}];
</script>
<ul>
<li ng-repeat="tag in tags">{{tag.name}}</li>
</ul>
</body>
</html>
The tags field cannot be resolved, because it is looked up in the $scope. I tried to access the tags field in my controller like this:
function TagList($scope, $rootScope) {
$scope.tags = $rootScope.tags;
}
But it doesn't work.
It works only if I include the TagList directly into the HTML page and render the JSON directly into this function.
How can I access the tags field in a separate js file in a Angular controller?