Losing Scope When Using Ng-Include

Losing scope when using ng-include

This is because of ng-include which creates a new child scope, so $scope.lineText isn’t changed. I think that this refers to the current scope, so this.lineText should be set.

Losing scope inside ng-include in angularJS

<div ng-include=ddValue1.url></div>

Try it. May be single qoute considering it as string rather than your scope propery

losing scope of ng-model when using ng-include (AngularJS)

Yupii...i found the solution..

here is solution:

<ul>
<label ng-repeat="opt in $parent.checkboxOptions">
<li>
<h4>
<label><input type="checkbox" name="checkbox" ng-model="$parent.$parent.selected[opt.option_value]" >{{opt.option_value}}</label>
</h4>
</li>
</label>
</ul>

ng-include lose data angularjs

I think that problem is that you are generating invalid html, you put div inside ul. So probably before angular starts, your browser fixing invalid html. It's similliar problem to own directive inside table, there are some solutions, first one, replace your ul and li tags with div or your div change to li another one, use a directive to replace those elements.

First try to replace this :

<form method="post" id="formQuestion" name="formQuestion" ng-submit="sendForm()" novalidate ng-controller="questionValidation">
<ul>

<div class="slide-animate" ng-include="'/templates/default/partials/_fields/f1.html'"></div>
<div class="slide-animate" ng-include="'/templates/default/partials/_fields/f2.html'"></div>

with this:

<form method="post" id="formQuestion" name="formQuestion" ng-submit="sendForm()" novalidate ng-controller="questionValidation">
<ul>

<li class="text-center slide-animate" ng-include="'/templates/default/partials/_fields/f1.html'"></li>
<li class="text-center slide-animate" ng-include="'/templates/default/partials/_fields/f2.html'"></li>

and f1 view:

<div>{{data | json}}</div>

Scope lost in ng-include and ng-submit does not submit form while ng-click does but without values of form

There are some problems in your code but as the first one I think you should use ng-submit directive on your form tag. like this:

<form name="{{formHolder.personForm}}" ng-submit="updateStatus(person.personID)">...</form>

with an <input type="submit" class="btn btn-success btn-lg btn-block"/> for the submit button inside your form.

But why don't you use the ng-repeat inside your form and pass the whole array to your submit function?

Passing scope-variables to ng-include

It's impossible, in this case better use directives.

angular.module('DirectiveExample', []).controller('Controller', ['$scope', function($scope) {  $scope.options = [1, 2, 3];  $scope.field = "Test";}]).directive('singlerow', function() {  return {    restrict: 'E',    scope: {      field: '=',      options: '=',    },    templateUrl: '/singlerow.html'  };});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><div ng-app="DirectiveExample"><script type="text/ng-template" id="/singlerow.html">  <div class="mm-FilterRow">    <div>Last Name:</div>    <div><i ng-hide="field">Loading...</i><select ng-show="options" ng-model="field" ng-options="o as o for o  in options"></select></div></div></script>
<div ng-controller="Controller"> <singlerow field="field" options="options"></singlerow> </div></div>

Can I nest a $scope variable inside an ng-include?

ng-include will already evaluate whatever you pass to it so there is no need to use {{}}. This will work

<div ng-include="cdn + 'logo.tpl'"></div>


Related Topics



Leave a reply



Submit