I need to call an AngularJS binding inside an inline javascript function. I cannot seem to have the data arrive there. Also, the format needs to arrive as a string.
Here is the inline javascript inside the HTML:
<body ng-view>
<script type="text/javascript">
$('#comments-container').comments({
profilePictureURL: 'https://viima-app.s3.amazonaws.com/media/user_profiles/user-icon.png',
youText: "Angular Binding" // HERE is where Angular binding needs to be called
},
roundProfilePictures: true,
textareaRows: 1,
enableAttachments: true,
getComments: function(success, error) {
var commentsArray = [{
id: 1,
created: '2015-10-01',
content: 'Lorem ipsum dolort sit amet',
fullname: 'Simon Powell',
upvote_count: 2,
user_has_upvoted: false
}];
success(commentsArray);
},
postComment: function(commentJSON, success, error) {
success(commentJSON);
},
putComment: function(data, success, error) {
setTimeout(function() {
success(data);
}, 500);
},
deleteComment: function(data, success, error) {
setTimeout(function() {
success();
}, 500);
},
upvoteComment: function(data, success, error) {
setTimeout(function() {
success(data);
}, 500);
},
uploadAttachments: function(dataArray, success, error) {
setTimeout(function() {
success(dataArray);
}, 500);
},
});
</script>
</body>
Here is the AngularJS Controller I intend to use for this portion:
(function () {
angular
.module('meanApp')
.controller('navigationCtrl', navigationCtrl);
navigationCtrl.$inject = ['$location','authentication'];
function navigationCtrl($location, authentication) {
var vm = this;
vm.isLoggedIn = authentication.isLoggedIn();
vm.currentUser = authentication.currentUser();
}
})();
Here is a sample template that utilizes this controller:
<div class="navbar navbar-default">
<div class="container">
<div id="navbar-main">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li ng-hide="navvm.isLoggedIn"><a href="login">Sign in</a></li>
<li ng-show="navvm.isLoggedIn"><a href="profile">{{ navvm.currentUser.name }}</a></li>
<li ng-show="navvm.isLoggedIn"><a href="login" onclick="logout()">Logout</a></li>
</ul>
</div>
</div>
</div>
I have commented inside the HTML where it needs to be.
Thanks in advance