0

Please help me to solve this problem.This angular code works locally but can not work in django template. I call this static files end of the body of base.html

<script src="{% static "js/angular.min.js" %}"></script>
<script src="{% static "js/restangular.min.js" %}"></script>
<script src="{% static "js/angular-ui-router.min.js" %}"></script>

This is contactlist.html

<div id="contactlist" ng-app="newApp">
    <div class="container" ng-controller="angCtrl">
        <h1 class="text-center">Search contact for {{myModel}}</h1>
        <form>
          <div class="input-group">
            <input type="text" class="form-control" ng-model="myModel" 
             placeholder="Search Contact">
            <div class="input-group-btn">
              <button class="btn btn-default" type="submit">
                <i class="fa fa-search"></i>
              </button>
            </div>
          </div>
        </form>

        <div class="all">
          <table class="table table-hover text-center">
            <thead>
              <tr>
                <th class="text-center">Id</th>
                <th class="text-center">Name</th>
                <th class="text-center">Contact Number</th>      
              </tr>
            </thead>
            <tbody>

              <tr ng-repeat="contact in contactlist | filter:myModel | 
                  orderBy: 'name'">
                <td>{{contact.id}}</td>
                <td>{{contact.name}}</td>
                <td>{{contact.contact}}</td> 
              </tr>

            </tbody>
          </table>
        </div>
    </div>
</div>

This is app.js

var app = angular.module('newApp', []);
app.controller('angCtrl', function($scope) {
    $scope.name = "";
});

app.controller('angCtrl', function($scope) {
    $scope.contactlist = [
      {id:'1',name:'raisul',contact:'+8801723844330'},
      {id:'2',name:'Rafikul',contact:'+8801723564330'},
      {id:'3',name:'Shariful',contact:'+8801726864330'},
      {id:'4',name:'kamarul',contact:'+8801723764330'},
      {id:'5',name:'Ashraful',contact:'+8801728864330'},
      {id:'6',name:'Jamarul',contact:'+8801723964330'},
      {id:'7',name:'Rahul',contact:'+8801723861330'},
      {id:'8',name:'Rashidul',contact:'+8801725864330'},
    ]

});

It shows the table element but can not show any data

Raisul Islam
  • 1,161
  • 1
  • 9
  • 18
  • AngularJS with Django - Conflicting template tags https://stackoverflow.com/questions/8302928/angularjs-with-django-conflicting-template-tags – mtt2p Jun 04 '17 at 16:38
  • Thank you. Please can you give me another link for restangular uses for beginner ? – Raisul Islam Jun 04 '17 at 16:51
  • @RaisulIslam try to join the IRC chat or gitter chat to get more interactive help while you're getting ramped up, generally speaking you want to leave the view rendering and template handling all to angular and just transfer the data you need to render the view. This will make developing and debugging a lot simpler and will keep the front and back end decoupled so you can write different service layer components or clients in different languages and just have a common JSON data interface. – shaunhusain Jun 04 '17 at 18:21

0 Answers0