0
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
    <div ng-app="canerApp" ng-controller="canerCtrl">
        <br> {{text}}f
    </div>
<script type="text/javascript">
var app = angular.module('canerApp', []);
app.controller('canerCtrl', function($scope){
    $scope.text ="ff";
});
</script>
</body>
</html>

this works and prints

fff

as you can see here

http://plnkr.co/edit/gP2NcC38JPsabQFacGkb?p=preview

but this doesnot work

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
    <div ng-app="myApp" ng-controller="myController">
        <br> {{text}}f
        <br> {{text}}fh
    </div>
<script type="text/javascript">
var app=  angular.module('myApp',[]);
app.controller('myController', function($scope){
    $scope.text="afasfa";
});
</script>
</body>
</html>

can be seen here https://plnkr.co/edit/1I90i5ANdrA6OUmZry65?p=preview

they totally same except controller and app nmes.

i spent one hour but couldnot figure out. ANd also couldnot find online error finders to validate if everything is true.

6
  • 2
    add https in your second code <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> Commented Aug 29, 2016 at 8:59
  • 1
    Above suggestion can be seen here Working fine now. Commented Aug 29, 2016 at 9:01
  • plnkr.co/edit/8UtFzxuoo50bIVNrNbNV?p=preview but why does ths work wthout https Commented Aug 29, 2016 at 9:03
  • 1
    again same issue, please check your link before pasting, check your url if it have https in it, if it have https then you have to use all the cdn using https protocol Commented Aug 29, 2016 at 9:08
  • 1
    if it has solve your problem can you please accept my answer as resolved? Commented Aug 29, 2016 at 9:13

2 Answers 2

3

Actually the difference is that in your first code you are using http protocol plnkr and in your second code you are using https plnkr and using http protocol for angular library.

So just change protocol to https in script tag.

Thanks to @Ashu Jha for plnk https://plnkr.co/edit/ivUsQBpop2864XP9s81s?p=preview

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

Comments

1

I usually use code.angular.org for my angular cdn site. And In case of yours http to https was the error. you can find these kind of bugs directly using console tab of the browser In your case error is

"Mixed Content: The page at 'https://plnkr.co/edit/1I90i5ANdrA6OUmZry65?p=preview' was loaded over HTTPS, but requested an insecure script 'http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js'. This request has been blocked; the content must be served over HTTPS."

Try This along with https.

<!DOCTYPE html>
<html>
<script src="https://code.angularjs.org/1.3.0/angular.js"></script>
<body>
    <div ng-app="myApp" ng-controller="myController">
         <br> {{text}}f
    </div>
    <script type="text/javascript">
        var app=  angular.module('myApp',[]);
        app.
        controller('myController', function($scope){
            $scope.text="afasfa";
        });
    </script>
</body>
</html>

Comments

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.