0

I have this simple app:

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>working app</title>
    <script type="text/javascript" src="static/js/angular.min.js"></script>

    <script type="text/javascript">
        angular.module('myApp', [])
            .controller('myCtrl', ['$scope', function($scope) {
                $scope.message = "Howdy!!";
            }])
            .config(['$interpolateProvider', function($interpolateProvider) {
                    $interpolateProvider.startSymbol('{a');
                    $interpolateProvider.endSymbol('a}');
            }]);
    </script>
</head>

<body ng-app="myApp">
<h1>Hello!</h1>
    <div ng-controller="myCtrl">
        <span>{message}</span>
        <span>{{ '{{message}}' }}</span>
    </div>


</body>

I'm getting {message} {{message}} in html page not scope value. I don't have any idea, where I'm going wrong. I really appreciate any sort of help in this!

7
  • what is the error in your console ? Commented Jul 16, 2016 at 20:10
  • What does "not working" mean? And why have you put {{ '{{message}}' }} - what is that supposed to be? Commented Jul 16, 2016 at 20:10
  • @Naga Sai: I'm not getting any error in my console. Commented Jul 16, 2016 at 20:11
  • @DanielRoseman: I'm getting, {message} {{message}} in my html page, not scope value. Commented Jul 16, 2016 at 20:12
  • 1
    But firstly, you've changed your angular syntax to {a ... a}, and second that still doesn't give any reason for wrapping a string inside Jinja tags. Commented Jul 16, 2016 at 20:22

1 Answer 1

3

To achieve your expected result, use below option to bind your scope value

{a message a} Start tag and end tag should be '{a' and 'a}' respectively without {{}} inside them

HTML:

<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>working app</title>


    <script type="text/javascript">

    </script>
</head>

<body ng-app="myApp">
<h1>Hello!</h1>
    <div ng-controller="myCtrl">

        <span>{a message a}</span>
    </div>


</body>

JS:

angular.module('myApp', [])
            .controller('myCtrl', ['$scope', function($scope) {
                $scope.message = "Howdy!!";
            }])
            .config(['$interpolateProvider', function($interpolateProvider) {
                    $interpolateProvider.startSymbol('{a');
                    $interpolateProvider.endSymbol('a}');
            }]);

Codepen= http://codepen.io/nagasai/pen/JKrVgV

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

1 Comment

Thanks! Understood my mistake :)

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.