Check tree - pass parametr to not check children - angularjs

I have this code http://plnkr.co/edit/kiH0Ge?p=preview
<!doctype html>
<html ng-app="plunker" >
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<choice-tree ng-model="myTree" children="true"></choice-tree>
<hr />
$scope.myTree = {{myTree | json}}
</body>
</html>
I've added parametr checkChildren
<choice-tree ng-model="myTree" checkChildren="true"></choice-tree>
Then in check directive I want to run function conditionally
if(scope.checkChildren === 'true')
checkChildren(choice);
But it doesn't work.
I know there is isolated scope, but how to build tree then.

Now everything works http://plnkr.co/edit/5lLGIQ?p=preview
I just changed children to withchildren and this (crucial)
$compile('<choice-tree ng-model="choice.children" children="{{children}}"></choice-tree>')(scope);
to
$compile('<choice-tree ng-model="choice.children" withchildren="'+scope.withchildren+'"></choice-tree>')(scope);
http://plnkr.co/edit/5lLGIQ?p=preview

If my understanding is correct, I think it is a simple typo.
With a little modification, it seems to be working: http://plnkr.co/edit/BJqsl3
You want to check bool value, e.g. scope.checkChildren === true not against 'true'
[edit] It seems I did not understand the spec correctly
If I remove the if statement which I pointed out above, and call
checkChildren(), it works.
Is this what you intend?
Plunk is updated accordingly.

Related

Why this simple Angular JS does not working? :(

This is the code.
(I know that I must type here so many text to post my question, but please ignore this part in the parenthesis. It is due only to the rules of the site.)
I can not find the reason, but on screen only appears "{{adat}}".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> </title>
<script src="https://code.angularjs.org/1.8.2/angular.js">
</script>
<script type="text/javascript">
function todoc($scope) {
$scope.adat = "Szia!";
}
</script>
</head>
<body ng-app>
<div ng-controller="todoc">
<h1> {{adat}} </h1>
</div>
</body>
</html>
It turned out that this version of Angular works with a newer syntax.
For this syntax the appropriate version is 1.0.0

Angular Mustache evaluation - why does this code behave this way?

In the following code:
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="utf-8">
<title>My HTML File</title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<script src="bower_components/angular/angular.js"></script>
</head>
<body>
<div id="div1" style="display:none;">This disappears</div>
<p>Nothing here {{2 + "3" + document.getElementById("div1").innerText + "." }}</p>
</body>
</html>
I expected to see an error or failing that I'd expect "23This disappears." What I do see is "23." (Notice the missing "This disappears")
It's obvious that the mustache is not doing a direct evaluation, but what is actually going on here?
The 2 is being converted into a string and then concatenated with the "3" string, because you can't concatenate an integer with a string.
AngularJS expressions are JavaScript-like code snippets that are evaluated by AngularJS in the context of the current model scope, rather than within the scope of the global context (window).
https://docs.angularjs.org/guide/expression

Error: 'Node' is undefined. javascript error

I have written the following code in the HTML file.
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<title>Project Tracking Home Page</title>
<script src="Scripts/jquery-2.1.0.min.js"></script>
<link href="CSS/bootstrap.min.css" rel="stylesheet" />
<link href="CSS/Site.css" rel="stylesheet" />
<script src="Scripts/bootstrap.min.js"></script>
<script src="Scripts/angular.min.js"></script>
</head>
<body>
<h1>Welcome To Project Tracker</h1>
<p>Addition of Two Numbers (100+100) is - {{100+100}}</p>
</body>
</html>
The binding expressions do not return the value instead they are shown as it is.
When i run this code, i find the error ''Node' is undefined.'
I have used NuGet packages to install the Angular Js and JQuery into the scripts folder.
Make sure that your browser's document mode is greater than IE 8
If it's IE, try this:
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

Initial state of checkbox?

Running this code by clicking checkbox returns true or false for {{isHidden}} as expected. But when the code is run for the very first time {{isHidden}} appear to be blank. How to fix this?
<!DOCTYPE html>
<html data-ng-app>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
Hidden: <input type="checkbox" ng-model="isHidden">{{isHidden}}
<script type="text/javascript" src="js/angular.js"></script>
</body>
</html>
use ng-init directive
<input type="checkbox" ng-model="isHidden" ng-init="isHidden= true">{{isHidden}}
use true or false in ng-init it will initialize the values on a scope
here is the working plunker

How to show alert in extjs?

While executing the following code in browser it will not shown an alert, its just shown empty page. anything wrong in the following code please help me.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text.html; charset=utf-8">
<title> First Program </title>
<link rel="stylesheet" type="text/css" href ="http://localhost:8080/ext/ext-4.2.1.883/resources/css/ext-all.css"/>
<script type = "text/javascript" src = "http://localhost:8080/ext/ext-4.2.1.883/ext-all-dev.js"/>
<script type="text/javascript">
Ext.onReady(function(){
// alert("We are ready to go!");
Ext.Msg.alert("Hello World");
});
</script>
</head>
<body>
</body>
</html>
You are not calling the method properly. Ext.Msg.alert takes two parameters, title and message, as you can see in the docs.

Resources