Lulzim Lulzim - 1 year ago 202
AngularJS Question

How to pass scope variable in ng-init using AngularJS

I have problem passing the variable declared from the scope to ng-init:

so far I have something like this:

$scope.x = '10';

<div ng-controller = "controller" ng-init="function(x)">

How do I pass x var from the scope inside ng-init function?

Answer Source

A lot of people will tell you you shouldn't do this (as mentioned in the docs here:

As for actually doing it....

<div ng-controller="controller" ng-init="x = x">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download