#AngularJS ng-model in ng-if Tutorial
a quick tip for those trying to get the ng-model directive working in your angularjs application within ng-if.
ng-if Child Scopes
If you are wanting to use an ng-model scope within an ng-if then you'll have to access that scope using $parent
Our html page will look something like so:
<html ng-app="testApp">
<head>
<title>AngularJS ng-if child scopes example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
</head>
<body ng-controller="testController">
<div ng-if="isFalse">
{{$parent.name}}
</div>
<p>{{name}}</p>
<div ng-if="isTrue">
<p>{{$parent.name}}</p>
</div>
<script src="script.js"></script>
</body>
</html>
And our controller looks something like this:
var testApp = angular.module("testApp", []);
testApp.controller("testController", function($scope) {
$scope.isTrue = false;
$scope.name = "Elliot";
});
Continue Learning
AngularJS Promises Tutorial
In this tutorial we examine the $q service and how we can chain promises.
Most Important Changes to AngularJS in 1.6
In this article we look at the most important changes to AngularJS in the latest upcoming release version 1.6.
AngularJS Data Binding Tutorial
This first lesson of the Angularjs course looks to teach how useful data binding is when using AngularJS
AngularJS Controllers Tutorial
this tutorial teaches the basics of angularjs controllers as well as introducing concepts such as constructor and scope inheritance within your angularjs application