Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create boilerplate for Angular 1.x #6

Open
stefek99 opened this issue Sep 23, 2015 · 3 comments
Open

Create boilerplate for Angular 1.x #6

stefek99 opened this issue Sep 23, 2015 · 3 comments

Comments

@stefek99
Copy link
Owner

@stefek99 stefek99 commented Sep 23, 2015

<!doctype html>
<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.min.js'></script>
    <script>
      var app = angular.module("app", []);

      app.controller("ctrl", function($scope) {
        $scope.message = "It works!";
      });

    </script>
  </head>
  <body ng-app="app" ng-controller="ctrl">
    {{ message }}

  </body>
</html>
@stefek99
Copy link
Owner Author

@stefek99 stefek99 commented Apr 14, 2017

<!doctype html>

<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js'></script>
    <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-route.js'></script>
    <script>
      var app = angular.module("app", ["ngRoute"]);

      app.config(function ($routeProvider) {
        $routeProvider
          .when('/home', {
            templateUrl: 'home.html'
          })
          .when('/login', {
            templateUrl: 'login.html',
            controller: "LoginCtrl"
          })
          .otherwise('/home')
      });

      app.controller("LoginCtrl", function($scope) {
        $scope.message = "It works!";
      });

    </script>
  </head>
  <body ng-app="app">

    <div ng-view></div>

    <script type="text/ng-template" id="home.html">
      <h1>Home</h1>
    </script>

    <script type="text/ng-template" id="login.html">
      <h1>Login</h1>
      {{ message }}
    </script>

  </body>
</html>
@stefek99
Copy link
Owner Author

@stefek99 stefek99 commented Apr 14, 2017

With Bootstrap

<!doctype html>

<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js'></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script>
      var app = angular.module("app", ['ui.bootstrap']);

      app.controller('ctrl', function ($scope) {
        
        $scope.alerts = [
          { type: 'danger', msg: 'Oh snap! Change a few things up and try submitting again.' },
          { type: 'success', msg: 'Well done! You successfully read this important alert message.' }
        ];

        $scope.addAlert = function() {
          $scope.alerts.push({msg: 'Another alert!'});
        };

        $scope.closeAlert = function(index) {
          $scope.alerts.splice(index, 1);
        };

      });
    </script>
  </head>
  <body ng-app="app">

    <div ng-controller="ctrl">

  <alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</alert>
  <button class='btn btn-default' ng-click="addAlert()">Add Alert</button>


    </div>

  </body>
</html>
@marsrobertson
Copy link

@marsrobertson marsrobertson commented Nov 19, 2019

With Bootstrap updated: https://angular-ui.github.io/bootstrap/

<!doctype html>

<html>
  <head>
    <script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.js'></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>

    <!-- https://getbootstrap.com/docs/3.3/getting-started/#download -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <meta name="viewport" content="width=device-width, initial-scale=1">

  </head>
  <body ng-app="app">

    <div ng-controller="AccordionDemoCtrl">
      <script type="text/ng-template" id="group-template.html">
        <div class="panel-heading">
          <h4 class="panel-title" style="color:#fa39c3">
            <a href tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" uib-accordion-transclude="heading">
              <span uib-accordion-header ng-class="{'text-muted': isDisabled}">
                {{heading}}
              </span>
            </a>
          </h4>
        </div>
        <div class="panel-collapse collapse" uib-collapse="!isOpen">
          <div class="panel-body" style="text-align: right" ng-transclude></div>
        </div>
      </script>
    
      <p>
        <button type="button" class="btn btn-default btn-sm" ng-click="status.open = !status.open">Toggle last panel</button>
        <button type="button" class="btn btn-default btn-sm" ng-click="status.isFirstDisabled = ! status.isFirstDisabled">Enable / Disable first panel</button>
      </p>
    
      <div class="checkbox">
        <label>
          <input type="checkbox" ng-model="oneAtATime">
          Open only one at a time
        </label>
      </div>
      <uib-accordion close-others="oneAtATime">
        <div uib-accordion-group class="panel-default" heading="Static Header, initially expanded" is-open="status.isFirstOpen" is-disabled="status.isFirstDisabled">
          This content is straight in the template.
        </div>
        <div uib-accordion-group class="panel-default" heading="{{group.title}}" ng-repeat="group in groups">
          {{group.content}}
        </div>
        <div uib-accordion-group class="panel-default" heading="Dynamic Body Content">
          <p>The body of the uib-accordion group grows to fit the contents</p>
          <button type="button" class="btn btn-default btn-sm" ng-click="addItem()">Add Item</button>
          <div ng-repeat="item in items">{{item}}</div>
        </div>
        <div uib-accordion-group class="panel-default" heading="Custom template" template-url="group-template.html">
          Hello
        </div>
        <div uib-accordion-group class="panel-default" is-open="status.isCustomHeaderOpen" template-url="group-template.html">
          <uib-accordion-heading>
            Custom template with custom header template <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.isCustomHeaderOpen, 'glyphicon-chevron-right': !status.isCustomHeaderOpen}"></i>
          </uib-accordion-heading>
          World
        </div>
        <div uib-accordion-group class="panel-danger" heading="Delete account">
          <p>Please, to delete your account, click the button below</p>
          <button class="btn btn-danger">Delete</button>
        </div>
        <div uib-accordion-group class="panel-default" is-open="status.open">
          <uib-accordion-heading>
            I can have markup, too! <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': status.open, 'glyphicon-chevron-right': !status.open}"></i>
          </uib-accordion-heading>
          This is just some content to illustrate fancy headings.
        </div>
      </uib-accordion>
    </div>

    <script>

        angular.module('app', ['ui.bootstrap']).controller('AccordionDemoCtrl', function ($scope) {
          $scope.oneAtATime = true;
    
          $scope.groups = [
            {
              title: 'Dynamic Group Header - 1',
              content: 'Dynamic Group Body - 1'
            },
            {
              title: 'Dynamic Group Header - 2',
              content: 'Dynamic Group Body - 2'
            }
          ];
    
          $scope.items = ['Item 1', 'Item 2', 'Item 3'];
    
          $scope.addItem = function() {
            var newItemNo = $scope.items.length + 1;
            $scope.items.push('Item ' + newItemNo);
          };
    
          $scope.status = {
            isCustomHeaderOpen: false,
            isFirstOpen: true,
            isFirstDisabled: false
          };
        });
    
    
        </script>

  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.