Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I want to use angular in my project to keep data of some partial views in one cache place. But when I started working on this I found that the code was working on sample project is no more working with my Project. It works fine on my layout page but do not good with my partial page.

What I have tried:

<script type="text/javascript" language="javascript">
        debugger;
        var myApp = angular.module('myApp', []);
        myApp.controller('abc', ['$scope'], function ($scope) {
            debugger;
            $scope.SomeId = "some id";
        });
</script>



Then in HTML I used ng-app = "myApp" in main div and then ng-controller = "abc" and ng-model = "SomeId" in input tag. I then tried to show {{SomeId}} or even simple expression like {{1+2}} and nothing is working. On debugging I came to know that the first debugger got the break but second one is not. Also browser is not showing any error.
Kindly help me the way out.
Posted
Updated 26-Jul-17 20:57pm
v7

1 solution

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script type="text/javascript" language="javascript">
        debugger;
        var myApp = angular.module('myApp', []);
        myApp.controller('abc', function ($scope) {
            debugger;
            $scope.SomeId = "some id";
        });
        </script>
<body>

<div ng-app="myApp">
<div ng-controller="abc">
<p>{{SomeId}}</p>
</div>
</div>

</body>
</html>


It worked. Only modified line is
myApp.controller('abc', function ($scope) {
 
Share this answer
 
Comments
Ammar4556257 27-Jul-17 3:21am    
Thanks for your time basically it is working in sample project but my question here is what could be the conflict that it is not working in my main project's partial views. It is also working on layout page as well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900