I am trying to show a <p> only in the HTTP protocol.
Here is what I have so far:
angular
.module('myApp',[])
.controller('myCtrl', ['$scope', '$window', function($scope, $window){
$scope.name = 'Superhero';
console.log('$window.location.protocol = ' + $window.location.protocol); // just checking
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<div ng-app="myApp">
<p ng-if="window.location.protocol === 'http:'">This needs to be shown in HTTP only.</p> <!-- doesnt work with $window either -->
<div ng-controller="myCtrl">
Hello, {{name}}!
</div>
</div>
This snippet doesnt work in both HTTP and HTTPS.
I am pretty sure the problem is about accessing the window object.
How do I fix this?
Edit: Note that the <p> does not have any controller.