Angularjs – Angular JS : $ is undefined


I am new to Angular js. I have tried the following code:

    <title>angular js</title>
    <script src="js/lib/jquery.min.js"></script>
    <script src="js/lib/angular.min.js"></script>
<body ng-app="MyApp" ng-controller="MyController">
    <input ng-model="data.selected">

    var app = angular.module('MyApp',[]);
        $ = "Initial Text";


I tried this code to show the initial text in the H1 tag.
But I got the error $ is undefined
What is wrong here? How can I solve this?

Best Solution

This isn't an AngularJS-specific issue, but a general JavaScript error.

in the controller you're accessing the field "selected" of something undefined. try

$ = {}; 
$"initial text"


$ = {selected : "initial text"};

Related Question