javascript - ng-class not properly working inside h1? -
i'm starting studying angularjs , wondering why code not working? wondering why h1 tag not getting orange ng-class="'orange'".
i know answer quite easy i'm starting.
here index.html:
<html ng-app="app"> <head> <style type="text/css"> </style> </head> <body> <div ng-controller="maincontroller"> <h1 ng-class="'orange'">hello there</h1> </div> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script> <script type="text/javascript" src="app.js"></script> </body> </html> and here app.js:
var app = angular.module('app', []); app.controller('maincontroller', function($scope) { }) p.s. no errors in console.
it must work. because resultant giving class direct string variable value orange single quotes.
it same defining scope variable returning value as
<h1 ng-class="class">hello there</h1> code
$scope.class='orange'; both approaches 1 same thing.
update
you need add css class changes
<style type="text/css"> .orange { color: orange; } </style>
Comments
Post a Comment