.net - Angular code not seeing controller and items -


i new angular trying create , mvc project angular. have create about.js file , code inside it:

(function () {     var app = angular.module('myapp', []);      app.controller('tecknologiescontroller', function () {         this.text = tech;     });     var tech = {         name: 'progamming',         csharp: 'c#',         asp: 'asp .net',         xaml:'xaml',         java: 'java',         sql: 'sql',         plsql: 'pl/sql',         xml: 'xml',         webs: 'web services'     } })(); 

i have added script tags body of _layout.cshtml file so:

<body>     <script type="text/javascript" src="angular.min.js"></script>     <script type="text/javascript" src="about.js"></script> 

in about.cshtml file have code show 1 of tech items in about.js code:

<div ng-app="myapp" ng-controller="tecknologiescontroller tech">     <div>{{tech.text.name}}</div> </div> 

but not working me. prints out {{tech.text.name}} text. adding script tags wrong or what? working fine here in fiddle: http://jsfiddle.net/pyh89/1/

ng-controller="tecknologiescontroller tech" makes 'tech' point this.

i think want is:

(function () {     var app = angular.module('myapp', []);      app.controller('tecknologiescontroller', function () {         this.tech = tech;     });     var tech = {         name: 'progamming',         csharp: 'c#',         asp: 'asp .net',         xaml:'xaml',         java: 'java',         sql: 'sql',         plsql: 'pl/sql',         xml: 'xml',         webs: 'web services'     } })(); 

and html:

<div>{{tech.tech.name}}</div> 

it better if var tech = ... declared , assigned before use it.

you this:

(function () {     var app = angular.module('myapp', []);      app.controller('tecknologiescontroller', function () {         var tech = this;         tech.name = 'programming;         tech.csharp = 'c#';         // etc ...     }); })(); 

which allow access name more directly

<div>{{tech.name}}</div> 

but since don't know trying do, that's best can answer @ point.

you main issue, think don't understand tech points to.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -